Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14836

Another ^A bug

Path csiph.com!4.us.feeder.erje.net!feeder.erje.net!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Martijn Dekker <martijn@inlv.org>
Newsgroups gnu.bash.bug
Subject Another ^A bug
Date Tue, 20 Nov 2018 18:24:04 +0100
Lines 37
Approved bug-bash@gnu.org
Message-ID <mailman.4314.1542734655.1284.bug-bash@gnu.org> (permalink)
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1542734656 29372 208.118.235.17 (20 Nov 2018 17:24:16 GMT)
X-Complaints-To action@cs.stanford.edu
To Bug reports for the GNU Bourne Again SHell <bug-bash@gnu.org>
Envelope-to bug-bash@gnu.org
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.9.1
Content-Language en-GB
X-detected-operating-system by eggs.gnu.org: GNU/Linux 3.x
X-Received-From 37.59.109.123
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14836

Show key headers only | View raw


That ^A / $'\1' character just keeps causing trouble...

This is a bug with IFS. Including a $'\1' character anywhere in IFS 
causes expansions in shell assignments to discard that character.

$ bash -c "c=$'Y\1Y';
     for IFS in $'\1' $'\2' $'x\1' $'x\2' $'\1x' $'\2x'; do
         v=X\${c}X;
         printf %s \"\$v\" | od -a | awk 'NR==1 { \$1=\"\"; print }';
     done"

Output on bash 4.4 and current git:
  X Y Y X
  X Y soh Y X
  X Y Y X
  X Y soh Y X
  X Y Y X
  X Y soh Y X

Expected output, on bash 4.3 and earlier, and all other shells:
  X Y soh Y X
  X Y soh Y X
  X Y soh Y X
  X Y soh Y X
  X Y soh Y X
  X Y soh Y X

Note that quoting the assigned value is an effective workaround. But in 
shell grammar, IFS should never have any influence on true shell 
assignments (as opposed to assignment-arguments) and quoting expansions 
should not be necessary. (This paragraph is included to pre-empt readers 
who would reply "just quote everything". Yes, I know. It's still a bug.)

Thanks,

- Martijn

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Another ^A bug Martijn Dekker <martijn@inlv.org> - 2018-11-20 18:24 +0100

csiph-web