[ovs-dev] [PATCH 1/3] ovn.at: Use {} to make this less ambiguous
Ben Pfaff
blp at ovn.org
Fri Nov 27 18:17:36 UTC 2015
On Thu, Nov 26, 2015 at 06:41:30PM +0900, YAMAMOTO Takashi wrote:
> While (surprisingly to me) bash interprets $10 as ${1}0,
> many other shells, including NetBSD's /bin/sh, interpret it as ${10}.
>
> Signed-off-by: YAMAMOTO Takashi <yamamoto at midokura.com>
Acked-by: Ben Pfaff <blp at ovn.org>
I guess that this is documented in the Autoconf manual, but I had never
really paid attention before:
'${10}'
The 10th, 11th, ... positional parameters can be accessed only
after a 'shift'. The 7th Edition shell reported an error if given
'${10}', and Solaris 10 '/bin/sh' still acts that way:
$ set 1 2 3 4 5 6 7 8 9 10
$ echo ${10}
bad substitution
Conversely, not all shells obey the Posix rule that when braces are
omitted, multiple digits beyond a '$' imply the single-digit
positional parameter expansion concatenated with the remaining
literal digits. To work around the issue, you must use braces.
$ bash -c 'set a b c d e f g h i j; echo $10 ${1}0'
a0 a0
$ dash -c 'set a b c d e f g h i j; echo $10 ${1}0'
j a0
More information about the dev
mailing list