[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: nullglob is documented incorrectly
From: |
Greg Wooledge |
Subject: |
Re: nullglob is documented incorrectly |
Date: |
Mon, 6 Nov 2023 09:15:34 -0500 |
On Mon, Nov 06, 2023 at 08:56:11AM -0500, Chet Ramey wrote:
> The null string (NULL) and the empty string ("") are not the same thing.
If this is true, then the man page has many inconsistencies that need
to be cleared up. For example, in the definition of PATH:
PATH The search path for commands. It is a colon-separated list of
directories in which the shell looks for commands (see COMMAND
EXECUTION below). A zero-length (null) directory name in the
value of PATH indicates the current directory. A null directory
name may appear as two adjacent colons, or as an initial or
trailing colon.
Obviously you can't have a NULL pointer in the middle of PATH's content,
when it's serialized as a single string full of colons. So "null" here
clearly refers to an empty (zero-length) string, at least prior to
whatever internal splitting may occur.
The word "null" is used in many places throughout the man page, and in
most of these, the context seems to say that it means the same as the
empty string. Parameter Expansion is one such place:
${parameter:-word}
Use Default Values. If parameter is unset or null, the expan‐
sion of word is substituted. Otherwise, the value of parameter
is substituted.
We know that if parameter contains the empty string, the Default Value
is used. Since the empty string case is never mentioned explicitly, one
is led to believe that "null" covers that case, possibly in addition to
the case where the variable is/contains a NULL pointer internally.
As far as NULL variables go, I assume this is how it appears:
unicorn:~$ unset -v x; x=""; declare -p x
declare -- x=""
unicorn:~$ unset -v x; declare x; declare -p x
declare -- x
with the first being an empty string, and the second being a NULL pointer.
If that's true, then it wouldn't hurt to spell that out explicitly
somewhere.