[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ${| command; } funsub not setting REPLY does not error out with 'set
From: |
Martin D Kealey |
Subject: |
Re: ${| command; } funsub not setting REPLY does not error out with 'set -u' active |
Date: |
Sat, 21 Dec 2024 06:11:22 +1000 |
On Sat, 21 Dec 2024, 04:01 Zachary Santer, <zsanter@gmail.com> wrote:
> On Fri, Dec 20, 2024 at 11:50 AM Greg Wooledge <greg@wooledge.org> wrote:
> > I don't think your definition of "explicit" matches mine.
>
> ${variable} and ${| command; } are explicit expansions in the sense
> that I had to write them in the script for the expansions they specify
> to be performed. As opposed to PS2, which bash will happily expand
> without the user having to type ${PS2} anywhere.
>
I'm with Greg on this.
At no point do we write «$REPLY» and that makes the expansion implicit not
explicit.
> > If I, as the programmer, managed to misspell REPLY or forget to set it
> in some codepath, I'd rather bash tell me
>
Those are two very different failure modes, and the fact that set -u
conflates them is most of the reason that some of us object so vehemently
to it.
>
That limitation of course is because - unlike most contemporary languages -
the shell fails to distinguish "unset" from "nonexistent".
(This lack also leads directly to some arcane behaviour around « local ».)
-Martin
- ${| command; } funsub not setting REPLY does not error out with 'set -u' active, Zachary Santer, 2024/12/18
- Re: ${| command; } funsub not setting REPLY does not error out with 'set -u' active, Lawrence Velázquez, 2024/12/18
- Re: ${| command; } funsub not setting REPLY does not error out with 'set -u' active, Chet Ramey, 2024/12/19
- Re: ${| command; } funsub not setting REPLY does not error out with 'set -u' active, Chet Ramey, 2024/12/23
- Re: ${| command; } funsub not setting REPLY does not error out with 'set -u' active, Zachary Santer, 2024/12/24
- Re: ${| command; } funsub not setting REPLY does not error out with 'set -u' active, Lawrence Velázquez, 2024/12/24
- Re: ${| command; } funsub not setting REPLY does not error out with 'set -u' active, Zachary Santer, 2024/12/25
- Re: ${| command; } funsub not setting REPLY does not error out with 'set -u' active, microsuxxor, 2024/12/25