[Top][All Lists]

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

Re: parameter expansion null check fails for arrays when [*] or [@] is u

From: Robert Elz
Subject: Re: parameter expansion null check fails for arrays when [*] or [@] is used
Date: Wed, 23 Mar 2022 18:56:07 +0700

    Date:        Wed, 23 Mar 2022 01:48:48 -0700
    From:        L A Walsh <bash@tlinx.org>
    Message-ID:  <623ADEF0.1060301@tlinx.org>

  |     POSIX phraseology applies to the POSIX language.

Which bash is an (extended) implementation of.

  | In 'C'

Completely irrelevant.

  | In perl:

Also irrelevant.

  | undef = unset

sh really has no concept of undefined variables
as there are no (required) declarations to define them.

Every conceivable variable exists, just most are unset.

"null" in POSIX is a shorthand for "null string" in which
the "string" part is kind of meaningless since all (set)
POSIX variables contain strings, and only strings.

You might not like the terminology, but it is what it is,
and you don't get to arbitrarily redefine it, unless you
change your name to Humpty Dumpty.

${var+word} tests if var is set.
${var:+word} tests if var is unset or null
which can also be done (depending upon context) as [ "$var" ]
(true if neither unset nor null) as unset vars expand
to null strings (assuming set +u).

  | ANSI defines '\0' as NUL.  Is that the same as null?

no.  completely unrelated, and absolutely irrelevant.

To revert a little to the original, in POSIX most of the
expansion ooerators applied to $* and $@ have unsoecified
resuklts, that is ${@%remove} is simply meaningless.
POSIX has no arrays (good thing) but I see no reason
why in an extended sh which does (like bash as one example)
using the @ or * magic array indexes should be any better
specified or meaningful when used with expansion modifiers.


ps: at least sh is consistent (with itself), unlike, say,
English.   What is "wind" (as just one example).

reply via email to

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