help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Should read -a respect quoted strings?


From: Gregory Bartholomew
Subject: Re: Should read -a respect quoted strings?
Date: Thu, 16 Oct 2025 18:23:02 -0500

On Thu, Oct 16, 2025 at 5:14 PM Martin D Kealey <martin@kurahaupo.gen.nz>
wrote:

> In relation to parsing commands, when “Word Splitting” refers to
> “unquoted”, it means characters that were not marked as quoted during the
> prior “Quote Removal” phase. Perhaps it could be made clearer that the
> «read» command does not apply quote removal at all, but in keeping with
> most parts of the man page, if it's not mentioned, then it's not supposed
> to happen. Indeed, the “Word Splitting” section starts with:
>
> The shell scans the results of parameter expansion, command substitution,
>> and arithmetic expansion that did not occur within double quotes for word
>> splitting.
>
>
> …which does not mention the «read» command, hence quote removal does not
> apply to the read command.
>
> (Personally, I feel “definition by omission” is not ideal, but it seems to
> have been the preferred approach for a long time.)
>
> -Martin
>

Thanks Martin.

I accidentally replied to Greg W. directly and didn't CC the mail list in
my reply. I'll paraphrase part of my previous reply here just for the
record.

I thought the sentence "That is, the word -d'' becomes -d after word
splitting and null argument removal." in the Word Splitting section might
be implying that quote removal should be happening. Under the
«read» section of the documentation, it states "One line is ... split into
words as described above under Word Splitting ...". But indeed, -d'' does
not become -d when piped through the read command, regardless of whether
the output is to scalar(s) or an array (-a).

Greg's helpful tip about using xargs was sufficient to resolve my specific
use case, so the issue is moot to me.

Thanks everyone.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]