All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: dash@vger.kernel.org
Subject: positional argument bug
Date: Thu, 05 May 2011 08:15:25 -0600	[thread overview]
Message-ID: <4DC2B0FD.1000802@redhat.com> (raw)
In-Reply-To: <4DC2AFF7.7070007@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1352 bytes --]

[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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

       reply	other threads:[~2011-05-05 14:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <BANLkTi=cmXee5Ej2fmhX2dp4FG6U3_1JqQ@mail.gmail.com>
     [not found] ` <20110504024128.GB8187@elie>
     [not found]   ` <BANLkTimmAWkEne0SYFDpc4Kq-4ChBJ_dWg@mail.gmail.com>
     [not found]     ` <BANLkTimUJX-asm1rBoKHKMH6HU8asWdLPA@mail.gmail.com>
     [not found]       ` <20110504050223.GG8187@elie>
     [not found]         ` <m3oc3ic2sc.fsf@linux-m68k.org>
     [not found]           ` <BANLkTi=n37vhi63Rh1YRh8uqxZ6cyR65wQ@mail.gmail.com>
     [not found]             ` <4DC2A4E8.7020904@case.edu>
     [not found]               ` <4DC2AFF7.7070007@redhat.com>
2011-05-05 14:15                 ` Eric Blake [this message]
2011-05-05 15:47                   ` positional argument bug Oleg Verych
2011-05-05 15:53                     ` Eric Blake
2011-05-20 23:59                   ` Herbert Xu
2011-05-21  8:53                     ` Harald van Dijk
2011-06-03 21:38                       ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DC2B0FD.1000802@redhat.com \
    --to=eblake@redhat.com \
    --cc=dash@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.