-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to [EMAIL PROTECTED] on 1/23/2006 6:52 AM: > > Description: > There is a behavior difference between bash 3.0 and 3.1. This results > in trouble installing oracle database software. in 3.0 `cmd` can > span over lines, in 3.1 not. > > Repeat-By: > > a=`echo 'a b c' | sed 's/ /\\ > /g' | grep 'b'` > echo $a
Or shorter: bash-3.0 $ echo `echo '\\ > a'` \ a bash-3.1.9 $ echo `echo '\\ > a'` \a Using 'set -xv' is useful here to seeing what bash is trying to do. bash 3.0 invokes the subcommand "echo '\[newline]a'" (after IFS splitting, the outer echo sees two parameters) while bash 3.1.9 invokes the subcommand "echo '\a" (the outer echo sees only one parameter). The difference here is the POSIX parsing rules (http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html). Section 2.3 token recognition states that in command substitution, "The shell shall read sufficient input to determine the end of the unit to be expanded (as explained in the cited sections). While processing the characters, if instances of expansions or quoting are found nested within the substitution, the shell shall recursively process them in the manner specified for the construct that is found." And in Section 2.6.3, inside backticks, backslash is only a quoting character if it is followed by $, `, or \. In your example, there is a backslash followed by another backslash, so the first \ is a quoting character per the rules of command substitution, but it occurs inside single quotes, where it must be a literal character per the rules of nested construct parsing. I think that the strict reading of POSIX is as follows - the first ` starts a command substitution, which then recursively parses to the end of the construct. During that search, backquote parsing does not recursively use single quoting rules (although unquoted single quotes must appear in matched pairs, or the results are undefined), but does see that the first \ quotes the second (and not the second quoting a newline). All the characters parsed form the final token, which is "`echo '\\[newline]a'", but which the command substitution sees as "echo '\[newline]a'. So I think you did find a regression - bash 3.0 is correct in preserving the newline between the quoted backslash and remaining characters, while bash 3.1 (through patchlevel 9) is incorrect in performing newline joining. - -- Life is short - so eat dessert first! Eric Blake [EMAIL PROTECTED] -----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/cFO84KuGfSFAYARAqLBAJ0Q57l+VEzUMy+RTp50KNcX3QjboACfWfP7 eJ4R7BRNhXl5TJAjCyvnFvA= =Crns -----END PGP SIGNATURE----- _______________________________________________ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash