[ovs-dev] [PATCH 1/3] ovn.at: Use {} to make this less ambiguous

Takashi Yamamoto yamamoto at midokura.com
Wed Dec 2 06:54:31 UTC 2015


On Sat, Nov 28, 2015 at 3:17 AM, Ben Pfaff <blp at ovn.org> wrote:
> 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>

pushed with the commit message updated as Simon suggested.

>
> I guess that this is documented in the Autoconf manual, but I had never
> really paid attention before:

thank you.

>
> '${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