bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[doc] confusion over $0 and positional parameters


From: Stephane Chazelas
Subject: [doc] confusion over $0 and positional parameters
Date: Wed, 27 Aug 2014 13:06:11 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

In

  info -f bash -n 'Invoking Bash'

we find:

> `-c'
>      Read and execute commands from the first non-option ARGUMENT after
>      processing the options, then exit.  Any remaining arguments are
>      assigned to the positional parameters, starting with `$0'.

$0 is generally *not* considered as a positional parameter. Both
POSIX
(http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_05_01)
and "info -f bash -n 'Positional Parameters'" have:

> A positional parameter is a parameter denoted by the decimal
> value represented by one or more digits, other than the single
> digit 0

explicitetly excluding $0.

That seems to be causing some confusion
https://unix.stackexchange.com/questions/152391

Maybe a better wording would be:

> `-c'
>      Read and execute commands from the first non-option ARGUMENT after
>      processing the options, then exit.  The first argument
>      after that is assigned to $0 which is used in error
>      messages for instance (in the abscence of arguments, $0
>      is assigned to the argv[0] that the interpreter received
>      (usually bash or sh)), and the following arguments are
>      assigned to the positional parameters.

The note of $0 being used for error messages would also be
useful as we see people using a place-holder like _ or -- there
causing more confusion. See for instance:

http://mywiki.wooledge.org/BashFAQ/012

-- 
Stephane




reply via email to

[Prev in Thread] Current Thread [Next in Thread]