Angus Leeming wrote: > Georg Baum wrote: >>> for arg in $@ >> >> This needs to be: >> >> for arg in "@" > > That's "$@" ?
Of course, sorry for the confusion. >> as I learned recently from André. Otherwise it would print the same >> wrong result even if the input was correct. > > Explanation please. >From the bash manpage, section "Special Parameters": @ Expands to the positional parameters, starting from one. When the expansion occurs within double quotes, each parameter expands to a separate word. That is, "$@" is equivalent to "$1" "$2" ... When there are no positional parameters, "$@" and $@ expand to nothing (i.e., they are removed). If the arguments are "a" "b b" "c", for arg in $@ expands to the four tokens a b b c. for arg in "$@" expands to the three tokens "a" "b b" "c". I don't know if this is POSIX behaviour or bash specific. Georg