Re: < "$@" doesn't expand properly?
Lawrence Velázquez <[email protected]> Sat, 04 Oct 2025 11:13:51 -0400
| Newsgroups | org.kernel.vger.dash |
|---|---|
| Message-ID | <[email protected]> |
On Sat, Oct 4, 2025, at 2:55 AM, Marc Chantreux wrote: > wow ... thank you so much for digging this. this is the second time > this year where oppose POSIX standard against consistency and ease of > use. > > I can understand why because most of the scripts I learned with were > postfixing the redirections so word splitting doesn't matter at this > point Sure it does. Redirections can be infixed, so these are all valid: <file cmd arg cmd <file arg cmd arg <file Someone who agrees with your argument should logically expect this to "work": set file arg cmd < "$@" >> Almost no shell works the way you are expecting, except for zsh in >> native mode (which I suspect is where you first tried this syntax) > > Not at all. Ah, well. I guessed so because I know from the zsh mailing lists that you're a big zsh fan. > As the behavior is undefined, of course, I would like to propose to > behave the most helpful way when it makes sense because > > * the other usecases are already doable: > * if the expected behavior is "$*", so use "$*" > * what's the point of A < "$@" ? use "$1" instead > * it's a matter of consistency to me. why "$@" can't behave as "$@" ? One could easily make the same "consistency" argument from the perspective of the redirection operator. POSIX disallows this expansion from producing multiple fields... var='foo bar' cmd < $var ...so why should this one produce multiple fields? set foo bar cmd < "$@" In any case, the existing behavior conforms to POSIX and is far more portable, so it is not likely to change. -- vq