bug-bash
[Top][All Lists]
Advanced

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

problem with {Z..a} and backticks


From: Stephane Chazelas
Subject: problem with {Z..a} and backticks
Date: Wed, 29 Jul 2015 14:11:45 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib  -D_FORTIFY_SOURCE=2 -g 
-O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat 
-Werror=format-security -Wall
uname output: Linux host 3.13.0-55-generic #94-Ubuntu SMP Thu Jun 18 00:27:10 
UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.3
Patch Level: 11
Release Status: release

Also reproduced with git head from a couple of weeks ago.

Description:

As {Z..a} includes the ` character, that seems to cause
confusion and can even cause commands to be executed:

$ bash -xc 'echo {Z..a}'
+ echo Z '[' '' ']' '^' _ '`' a
Z [  ] ^ _ ` a

OK (well, see how the backslash between [ and ] was removed), but:

$ bash -xc 'echo {Z..a}x'
bash: bad substitution: no closing "`" in `x

$ bash -xc 'echo {Z..a}uname`id -u`'
++ id -u
++ id -u
++ id -u
++ id -u
++ id -u
++ id -u
++ uname
++ id -u
+ echo Zuname1000 '[uname1000' uname1000 ']uname1000' '^uname1000' _uname1000 
'Linuxid -u`' auname1000
Zuname1000 [uname1000 uname1000 ]uname1000 ^uname1000 _uname1000 Linuxid -u` 
auname1000

See how for `, uname was executed, but not id -u.

Since like ksh93, bash only allows ASCII a-zA-Z for the range
boundaries, it may be better to reject mixed-case ranges like
ksh93 does, or do like zsh and accept any character and sort by
codepoint (may not be possible/desirable the way braces are
expanded early in bash).

-- 
Stephane



reply via email to

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