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 18:06:32 +0200
User-agent:
Telnet/1.0 [tlh] (PDP11/DEC)
Le 02/10/2021 à 15:09, Greg Wooledge écrivait :
On Sat, Oct 02, 2021 at 01:41:35PM +0200, Léa Gris wrote:
$ declare -f hello
hello ()
{
echo 'hello';
echo 'world'
}
The issue is that in some circumstances, newline characters may be handled
as space, making the function declaration invalid.
Can you show an example where the output of declare -f is invalid?
hello (){ echo 'hello';echo 'world';}
LC_MESSAGES=C sudo bash -c "$(declare -f hello);hello"
hello
world
LC_MESSAGES=C sudo -i bash -c "$(declare -f hello);hello"
bash: -c: line 2: syntax error: unexpected end of file
Better illustrated how newlines are discarded:
$ sudo bash -c 'echo hello
echo world'