All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harald van Dijk <harald@gigawatt.nl>
To: dash@vger.kernel.org
Subject: Re: positional argument bug
Date: Sat, 21 May 2011 10:53:32 +0200	[thread overview]
Message-ID: <1305968012.28004.6.camel@linux> (raw)
In-Reply-To: <20110520235950.GA1839@gondor.apana.org.au>

On Sat, 2011-05-21 at 09:59 +1000, Herbert Xu wrote:
> Eric Blake <eblake@redhat.com> wrote:
> >
> >> 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}.
> 
> I don't think any of this explicitly states that $10 cannot be
> interpreted as ${10}.  All it says is that where the first character
> is an underscore or alphabetic, then the longest name should be
> used, and that to use $10 portably you must put braces around it.

I agree that the last quotes are not convincing. In fact, they seem to
be saying that $10 must be interpreted as ${}10: there's no "if there is
no name, use a single-character symbol". The first, however:

> "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."

does say the braces are optional in ${1}0, so if a script author changes
${1}0 to $10, there should be no change in behaviour.

Cheers,
Harald


  reply	other threads:[~2011-05-21  9:06 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                 ` positional argument bug Eric Blake
2011-05-05 15:47                   ` Oleg Verych
2011-05-05 15:53                     ` Eric Blake
2011-05-20 23:59                   ` Herbert Xu
2011-05-21  8:53                     ` Harald van Dijk [this message]
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=1305968012.28004.6.camel@linux \
    --to=harald@gigawatt.nl \
    --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.