[Top][All Lists]

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

Re: Wrong parsing of backslash inside backquote

From: Chet Ramey
Subject: Re: Wrong parsing of backslash inside backquote
Date: Fri, 10 Mar 2006 17:12:36 -0500
User-agent: Thunderbird 1.5 (Macintosh/20051201)

address@hidden wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: ia64
> OS: linux
> Compiler: gcc -I/usr/src/packages/BUILD/bash-3.1 
> -L/usr/src/packages/BUILD/bash-3.1/../readline-5.1
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='ia64' 
> -DCONF_OSTYPE='linux' -DCONF_MACHTYPE='ia64-suse-linux' -DCONF_VENDOR='suse' 
> -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   
> -I.  -I. -I./include -I./lib   -O2 -fmessage-length=0 -Wall 
> -fbranch-probabilities
> uname output: Linux sykes 2.6.16-rc5-git9-2-default #1 SMP Tue Mar 7 14:56:34 
> UTC 2006 ia64 ia64 ia64 GNU/Linux
> Machine Type: ia64-suse-linux
> Bash Version: 3.1
> Patch Level: 11
> Release Status: release
> Description:
>       A backslash inside `...` leads to a parse error when it is the
>       last character in a single quoted string.
> Repeat-By:
>       $ cat x.sh
>       foo `bar 'a\'`
>       $ sh x.sh
>       x.sh: line 1: unexpected EOF while looking for matching `''
>       x.sh: line 2: syntax error: unexpected end of file

Applying the updated patch 10 as distributed here and on ftp.case.edu
would have fixed this problem.  (No, I have received no answer from
the folks who run ftp.gnu.org in response to my attempts to replace
the version of patch 10 there.)

z3(1)$ cat x5
foo `bar 'a\'`
z3(1)$ ./bash ./x5
./x5: line 1: bar: command not found
./x5: line 1: foo: command not found
z3(1)$ ./bash --version
GNU bash, version 3.1.11(9)-release (powerpc-apple-darwin8.3.0)
Copyright (C) 2005 Free Software Foundation, Inc.

However, in the long run, it's hopeless to try and recursively parse
quoted strings and shell expansions inside `` and retain backwards
compatibility with the Bourne shell, despite what POSIX says.  The
problem only gets worse when considering double-quoted strings.

``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet )
                                           Live Strong.  No day but today.
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

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