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


Groups > gnu.bash.bug > #11276

problem with {Z..a} and backticks

Path csiph.com!aioe.org!news.glorb.com!usenet.stanford.edu!not-for-mail
From Stephane Chazelas <stephane.chazelas@gmail.com>
Newsgroups gnu.bash.bug
Subject problem with {Z..a} and backticks
Date Wed, 29 Jul 2015 14:11:45 +0100
Lines 51
Approved bug-bash@gnu.org
Message-ID <mailman.7604.1438175516.904.bug-bash@gnu.org> (permalink)
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Trace usenet.stanford.edu 1438175516 4335 208.118.235.17 (29 Jul 2015 13:11:56 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org, bash@packages.debian.org
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=2tSNEEGUGwHfPza74zv6OAXUNls2DlouuobYXp0WToY=; b=npcH+F9hkl8MSR+D20/NO+yLq1H2g/FaUjny4hiVJLbT8cDLTtrwzfr9U2BqSUcaKu /+sXxbs8/+1kIRwEZK7FLPGnR22C5X/HV4NUhPCwgLrfvTZtTLLbzHpCS1jAUa96hvMY gKcAGWSFvRnnj8rptYCi9AZYxKGIy5A5UwfXGjInG3XLUw0Qns9GVvcN+PKRp4zQDfxU ouzKIrzj9DRK55TQg5IQDL3dOjI35Vx2nrlIS4y0oNvozOE32Q6i+2WRNfqD5xs9fgAi EpGIPY5+c+8eooq/VimQ/4oPdM+VQ28EaYLi09oA5b/5NjWjO1KwRCYtxgFaujiCGVUZ Pz2g==
X-Received by 10.180.88.196 with SMTP id bi4mr6085533wib.70.1438175507697; Wed, 29 Jul 2015 06:11:47 -0700 (PDT)
Content-Disposition inline
User-Agent Mutt/1.5.21 (2010-09-15)
X-detected-operating-system by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value).
X-Received-From 2a00:1450:400c:c05::229
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.14
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 aioe.org gnu.bash.bug:11276

Show key headers only | View raw


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

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


Thread

problem with {Z..a} and backticks Stephane Chazelas <stephane.chazelas@gmail.com> - 2015-07-29 14:11 +0100

csiph-web