From: "Lawrence Velázquez" <vq@larryv.me>
To: "Marc Chantreux" <mc@unistra.fr>
Cc: dash@vger.kernel.org
Subject: Re: < "$@" doesn't expand properly?
Date: Sat, 04 Oct 2025 11:13:51 -0400 [thread overview]
Message-ID: <cff17249-7e9d-47f9-aca1-ef1bfa5cd32a@app.fastmail.com> (raw)
In-Reply-To: <aODE8547kOvhQPIf@prometheus>
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
next prev parent reply other threads:[~2025-10-04 15:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-03 22:47 < "$@" doesn't expand properly? Marc Chantreux
2025-10-03 23:31 ` Lawrence Velázquez
2025-10-04 6:55 ` Marc Chantreux
2025-10-04 11:42 ` Harald van Dijk
2025-10-04 13:31 ` Marc Chantreux
2025-10-04 15:13 ` Lawrence Velázquez [this message]
2025-10-05 7:21 ` Marc Chantreux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cff17249-7e9d-47f9-aca1-ef1bfa5cd32a@app.fastmail.com \
--to=vq@larryv.me \
--cc=dash@vger.kernel.org \
--cc=mc@unistra.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox