[Top][All Lists]

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

Re: Request change to output of declare -f funcname

From: Chet Ramey
Subject: Re: Request change to output of declare -f funcname
Date: Sun, 3 Oct 2021 16:50:56 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0

On 10/2/21 1:02 PM, Léa Gris wrote:
Le 02/10/2021 à 18:45, Greg Wooledge écrivait :
On Sat, Oct 02, 2021 at 06:06:32PM +0200, Léa Gris wrote:
Better illustrated how newlines are discarded:

$ sudo bash -c 'echo hello
echo world'

$ sudo -i bash -c 'echo hello
echo world'
helloecho world

OK, that's news to me.  But that looks like a bug in sudo.  Asking bash
to change its behavior to work around a bug in some other program seems
like misdirected effort.

It is not wholly misdirected since Bash already add semicolon after statements where it is optional since these are followed by newlines.

Adding a semicolon after the last statement of a command group would not hurt in any circumstance.

But what would such a change help, other than to avoid the consequences of
what appears to be a bug in `sudo -i'?

Now while reworking the output of declare -f, there could be an option to produce the most compact output without newlines and without indentation; for the purpose of serializing function declarations, similarly as declare -p already serialize variables declaration in a compact one-line even for arrays.

Corollary declare -p could have an indented expanded output that would be useful for arrays with an element per line rather than space delimited elements.

If you'd like to see these changes, maybe do a sample implementation that
you (and others, if you'd like) can evaluate?

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

reply via email to

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