public inbox for dash@vger.kernel.org
 help / color / mirror / Atom feed
From: Marc Chantreux <mc@unistra.fr>
To: Harald van Dijk <harald@gigawatt.nl>
Cc: "Lawrence Velázquez" <vq@larryv.me>, dash@vger.kernel.org
Subject: Re: < "$@" doesn't expand properly?
Date: Sat, 4 Oct 2025 15:31:59 +0200	[thread overview]
Message-ID: <aOEhz5PAKi-xYg28@prometheus> (raw)
In-Reply-To: <ab0f8c73-ffac-4817-bd87-dcebe21453bd@gigawatt.nl>

[-- Attachment #1: Type: text/plain, Size: 1859 bytes --]

On Sat, Oct 04, 2025 at 12:42:30PM +0100, Harald van Dijk wrote:
> 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

wow ... another thing I ignored after more than 25 years of shell
scripting.

"case $foo" is another example I discovered recently (on this mailing
list AFAIR). The person who answered me talked about a "scalar context".

> 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.

Well ... I see a lot of people who just recomends to quote (and even brace)
everything (so $foo becomes "${foo}" in their coding style) just because
they fear expansions. I try to explain that expansions are good and word
splitting is useful but you have to be carreful but the more we have
exceptions to a simples rules, the more people will try to avoid errors and
go on quoting, losing the benefits of expansions. They finally
claim that "we should rewrite in python instead because shell behavior
is hard to understand".

However un fully understand than when a behavior is still used,
implementors try to make it consistent.  Thank you so much for your explainations.

regards.

-- 
Marc Chantreux
Pôle CESAR (Calcul et services avancés à la recherche)
Université de Strasbourg
14 rue René Descartes,
BP 80010, 67084 STRASBOURG CEDEX
03.68.85.60.79


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2025-10-04 13:32 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 [this message]
2025-10-04 15:13     ` Lawrence Velázquez
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=aOEhz5PAKi-xYg28@prometheus \
    --to=mc@unistra.fr \
    --cc=dash@vger.kernel.org \
    --cc=harald@gigawatt.nl \
    --cc=vq@larryv.me \
    /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