bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bash-3.1 Official patch 10


From: Eric Blake
Subject: Re: Bash-3.1 Official patch 10
Date: Thu, 23 Feb 2006 06:15:01 -0700
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Greg Schafer on 2/21/2006 8:20 PM:
> 
> status=`echo '-'| { ${GREP} -E -e 'a\' >/dev/null 2>&1 ; echo $?; }`

Even shorter - from the command line:

bash-3.1.9 $ echo `echo 'a\'`
a\

bash-3.1.10 $ echo `echo 'a\'`
>    # Oops, bash is still looking for input
> [Ctrl-c]
bash-3.1.10 $ echo `echo 'a\\'`   # Some hint as to what went wrong
a\


> 
> AFAICT, this used to be accepted by older Bash versions.
> 
> Do think problem lies with this Bash patch or with test case?

The bug is in official patch 10.  POSIX parsing rules
(http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html)
state in step 5 of 2.3 token recognition that on the first `, the shell
parses until the end of the command substitution, and in 2.6.3 command
substitution, that when parsing a command substitution the backslash
retains its literal meaning except when followed by $, `, or \.  In this
case, it is followed by ', so the nested command should be "echo 'a\'".

However, patch 10 only affected backticks:

bash-3.1.10 $ echo $(echo 'a\')
a\

So as a workaround, the test can be rewritten:

status=$(echo '-'| { ${GREP} -E -e 'a\' >/dev/null 2>&1 ; echo $?; })

- --
Life is short - so eat dessert first!

Eric Blake             ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFD/bVV84KuGfSFAYARAiEbAKCeC83Ke7kXKa61wgYt4JUn6hYSEwCdF9iu
wck5gmcvRR8d6u285MLP6To=
=GK+O
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]