[originally brought up on the bash list as a NetBSD bug, but dash is also affected] On 05/05/2011 08:11 AM, Eric Blake wrote: >> I'd call that a pretty serious incompatibility on the part of ash and its >> descendants (BSD sh, dash, etc.). There's no good reason that >> >> set -- a b c d e f g h i j >> echo $10 >> >> should echo `j'. > > Also a POSIX violation: > > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02 > > "The parameter name or symbol can be enclosed in braces, which are > optional except for positional parameters with more than one digit or > when parameter is followed by a character that could be interpreted as > part of the name." Additionally from POSIX: "If the parameter name or symbol is not enclosed in braces, the expansion shall use the longest valid name (see XBD Name)" "In the shell command language, a word consisting solely of underscores, digits, and alphabetics from the portable character set. The first character of a name is not a digit." Therefore, in "$10", 10 is not a name, so the longest name is the empty string, and the single-character symbol is used instead, such that this MUST be parsed as ${1}0, not as ${10}. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org