bug-bash
[Top][All Lists]
Advanced

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

Re: Request change to output of declare -f funcname


From: Léa Gris
Subject: Re: Request change to output of declare -f funcname
Date: Sat, 2 Oct 2021 19:02:30 +0200
User-agent: Telnet/1.0 [tlh] (PDP11/DEC)

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'
hello
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.

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.

These changes to the serialization of declare -f and -p would not affect backward or forward compatibility between serialization types. It would make the declare -f more resilient to newline removal and would allow both compact and indented verbose formatted outputs to coexist.




reply via email to

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