Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14110 > unrolled thread

Documentation for a="$@"

Started byIlkka Virta <itvirta@iki.fi>
First post2018-05-19 22:40 +0300
Last post2018-05-19 22:40 +0300
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug


Contents

  Documentation for a="$@" Ilkka Virta <itvirta@iki.fi> - 2018-05-19 22:40 +0300

#14110 — Documentation for a="$@"

FromIlkka Virta <itvirta@iki.fi>
Date2018-05-19 22:40 +0300
SubjectDocumentation for a="$@"
Message-ID<mailman.88.1526758841.1292.bug-bash@gnu.org>
In Bash, using "$@" in an assignment, (as in  a="$@" ) concatenates the 
positional parameters to single string, joined with spaces. Somewhat 
similarly to what "$*" does, except that $* uses the first letter of 
IFS, but $@ always uses a space.

However, I can't see this documented in the manual, is it somewhere?


"3.4 Shell Parameters" [1] discusses assignments to variables, and 
there's the phrase: "Word splitting is not performed, with the exception 
of "$@" as explained below." But the actual explanation seems to be 
missing, as there's no other mention of $@ on the page.

There's also no mention of assignments under "3.4.2 Special Parameters" 
[2]. It simply states that "$@" expands to separate words.


I'd suggest adding something like this to the description of $@ in 3.4.2:

""
If $@ or "$@" is used on the right hand side of an assignment to a 
variable, it instead expands to a single word with the value of each 
positional parameter separated by a space. That is, a="$@" is equivalent 
to a="$1 $2 ...".
""



(It seems the online manual is an older version than that in git, but I 
didn't see this mentioned in the devel version of the manual either.)


[1] https://www.gnu.org/software/bash/manual/html_node/Shell-Parameters.html
[2] 
https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html


-- 
Ilkka Virta / itvirta@iki.fi

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web