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

2021-01-08 Thread Ilkka Virta
On Fri, Jan 8, 2021 at 4:06 PM Chet Ramey  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.


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

2021-01-08 Thread Chet Ramey

On 1/8/21 4:05 AM, William Park wrote:

Another issue I came across.

 declare -p name=value

thinks 'name=value' is the variable.  My reading of manpage seems to say
'name' should be used, but not sure.  Is this a bug?


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

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



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

2021-01-08 Thread Eli Schwartz

On 1/8/21 4:05 AM, William Park wrote:

Another issue I came across.

 declare -p name=value

thinks 'name=value' is the variable.  My reading of manpage seems to say
'name' should be used, but not sure.  Is this a bug?

Workaround is, of course, use separate lines,
 declare name=value
 declare -p name


There's an obvious inference here, that declare -p only prints, does not 
create/modify, and only accepts NAMEs, therefore the optional [=VALUE] 
available to other modes will not be interpreted the way you seem to 
think it will be, in *this* mode.


--
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User



OpenPGP_signature
Description: OpenPGP digital signature


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

2021-01-08 Thread William Park
Another issue I came across.

declare -p name=value

thinks 'name=value' is the variable.  My reading of manpage seems to say
'name' should be used, but not sure.  Is this a bug?  

Workaround is, of course, use separate lines,
declare name=value
declare -p name
-- 
William Park