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: Peng Yu
Subject: Re: Why is -- in the output of declare -p x?
Date: Thu, 26 Jan 2023 08:13:27 -0600

Thanks for pointing this out. This justifies that -- should be removed
unless it is absolutely necessary. So far I don't see that it is
absolutely necessary.

On 1/25/23, Lawrence Velázquez <vq@larryv.me> wrote:
> 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
>


-- 
Regards,
Peng



reply via email to

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