DASH Shell discussions
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Harald van Dijk <harald@gigawatt.nl>
Cc: dash@vger.kernel.org
Subject: Re: positional argument bug
Date: Fri, 03 Jun 2011 15:38:01 -0600	[thread overview]
Message-ID: <4DE95439.2090404@redhat.com> (raw)
In-Reply-To: <1305968012.28004.6.camel@linux>

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

On 05/21/2011 02:53 AM, Harald van Dijk wrote:
>>> 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.

Given the confusing wording in POSIX, I've opened up a bug report:

http://austingroupbugs.net/view.php?id=458

Once it is resolved, it will either put the burden on dash to become
compliant ($10 is unambiguously ${1}0, Option 1), or put the burden on
compliant shell scripts to avoid $10 (both historical ${1}0 and dash
${10} behaviors are permitted, Option 2).  It will be interesting to see
which way the POSIX folks go on this one.

-- 
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-06-03 21:38 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
2011-06-03 21:38                       ` Eric Blake [this message]

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=4DE95439.2090404@redhat.com \
    --to=eblake@redhat.com \
    --cc=dash@vger.kernel.org \
    --cc=harald@gigawatt.nl \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox