Re: < "$@" doesn't expand properly?

Harald van Dijk <[email protected]> Sat, 4 Oct 2025 12:42:30 +0100
Newsgroups org.kernel.vger.dash
Message-ID <[email protected]>
Hi,

On 04/10/2025 07:55, Marc Chantreux wrote:
> * it's a matter of consistency to me. why "$@" can't behave as "$@" ?

The word that follows a redirection operator is one of the special 
contexts where operations that split words into multiple fields are 
disabled for it. Variable assignment is another. This is why

   foo='multiple words'
   bar=$foo
   echo $foo > $bar

writes the string "multiple words" to a file named "multiple words". The 
second line does not run a "words" command (as 'bar=multiple words' 
would suggest), and the third line does not create a file called 
"multiple" (as 'echo multiple words > multiple words' would suggest).

It is this principle that dash follows when it expands "$@" as "$*" in 
these contexts. I agree with you that if users want that, they can just 
write "$*" instead, but I do think that when users do write "$@" anyway, 
treating it as "$*" is the least questionable interpretation.

Cheers,
Harald van Dijk