[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why is -- in the output of declare -p x?
From: |
Kerin Millar |
Subject: |
Re: Why is -- in the output of declare -p x? |
Date: |
Wed, 25 Jan 2023 17:30:20 +0000 |
On Wed, 25 Jan 2023 11:06:15 -0600
Peng Yu <pengyu.ut@gmail.com> wrote:
> After all, the program which uses -p has control to what variable
> names should be used. It can choose variable names such that -- is
> never needed, in such case, those programs never need to test whether
> there is -- or not.
Consider the ramifications of the latter paragraph of Koichi's response. 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.
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.
--
Kerin Millar
- Why is -- in the output of declare -p x?, Peng Yu, 2023/01/24
- Re: Why is -- in the output of declare -p x?, Koichi Murase, 2023/01/25
- Re: Why is -- in the output of declare -p x?, Peng Yu, 2023/01/25
- Re: Why is -- in the output of declare -p x?,
Kerin Millar <=
- Re: Why is -- in the output of declare -p x?, Lawrence Velázquez, 2023/01/25
- Re: Why is -- in the output of declare -p x?, Peng Yu, 2023/01/26
- Re: Why is -- in the output of declare -p x?, Lawrence Velázquez, 2023/01/26
- Re: Why is -- in the output of declare -p x?, Peng Yu, 2023/01/26
- Re: Why is -- in the output of declare -p x?, Kerin Millar, 2023/01/26
- Re: Why is -- in the output of declare -p x?, alex xmb ratchev, 2023/01/25