bug-bash
[Top][All Lists]
Advanced

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

Re: declare -p name=value thinks 'name=value' is variable


From: Ilkka Virta
Subject: Re: declare -p name=value thinks 'name=value' is variable
Date: Fri, 8 Jan 2021 16:44:51 +0200

On Fri, Jan 8, 2021 at 4:06 PM Chet Ramey <chet.ramey@case.edu> wrote:

> No. `declare -p' does not accept assignment statements.
>

The synopsis in the documentation doesn't make it clear, though. It shows
only one case with -p and assignment, while the similar case of export -p
is listed separately from the other forms of export. Well, at least in my
5.0 man page, not on the online manual, though. Also, the documentation
doesn't seem to say the assigned value is ignored with -p, even though it
does say additional options are ignored.

So, suggest changing the synopsis from

  declare [-aAfFgiIlnrtux] [-p] [name[=value] …]

to something like:

  declare [-aAfFgiIlnrtux] [name[=value] …]
  declare [-aAfFgiIlnrtux] -p [name…]

And/or add to:

  "The -p option will display the attributes [...] additional options,
other than -f and -F, are ignored."

something like

  "An assignment cannot be used with the -p option."

Also, the error message should probably be "invalid variable name" like you
get for referring to something like that via ${!var}, instead of "not
found".

Since I mentioned export, export -p foo doesn't seem to do anything, even
if foo is exported, not even give an error. But, contrary to declare,
export -p foo=bar
_does_ assign the value, silently. Confusing.


reply via email to

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