help-bash
[Top][All Lists]
Advanced

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

Re: Why is -- in the output of declare -p x?


From: Lawrence Velázquez
Subject: Re: Why is -- in the output of declare -p x?
Date: Wed, 25 Jan 2023 23:05:33 -0500
User-agent: Cyrus-JMAP/3.9.0-alpha0-85-gd6d859e0cf-fm-20230116.001-gd6d859e0

On Wed, Jan 25, 2023, at 12:30 PM, Kerin Millar wrote:
> As was stated, it is potentially useful for a program that 
> processes the output of `declare -p` to be able to assume that the 
> second word always defines the attributes and that the variable 
> assignment always begins from the third word. Regardless of whether you 
> agree, and regardless of whether parsing declare may be a bad idea to 
> begin with, it is all but guaranteed that somebody, somewhere, will 
> have written a script that does exactly that. Breaking their scripts 
> for some (arguably) ineffectual brevity does not strike me as being a 
> good trade-off.

+1

> Another (unrelated) consideration is that the present behaviour ensures 
> that all of the variable names are neatly left-aligned. I would find 
> the output of `declare -p` harder to peruse if that were not the case.

Unfortunately, variables with multiple attributes throw a wrench
into this :(

        $ x=10
        $ declare -irx y=20
        $ declare -p x y
        declare -- x="10"
        declare -irx y="20"

-- 
vq



reply via email to

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