[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug in 'set -n' processing
From: |
Eric Blake |
Subject: |
bug in 'set -n' processing |
Date: |
Fri, 03 Jun 2011 12:39:52 -0600 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.10 |
Bash has a bug: ${+} is syntactically invalid, as evidenced by the error
message when running the script, yet using 'set -n' was not able to flag
it as an error.
$ echo $BASH_VERSION
4.2.8(1)-release
$ bash -c 'echo ${+}'; echo $?
bash: ${+}: bad substitution
1
$ bash -cn '${+}'; echo $?
0
$ ksh -cn '${+}'; echo $?
ksh: syntax error at line 1: `+' unexpected
3
Meanwhile, a feature request: since $+ outputs a literal "$+", it is
proof that + cannot be a valid variable name. Bash should follow ksh'
lead by having 'set -n' warn about suspicious but usable constructs, at
least when --posix is not in effect.
$ bash -c 'echo $+'
$+
$ bash -cn '$+'; echo $?
0
$ ksh -cn '$+'; echo $?
ksh: warning: line 1: $ not preceded by \
0
--
Eric Blake address@hidden +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- bug in 'set -n' processing,
Eric Blake <=