Currently
declare -f funcname
prints the function source with ending the last statement/command with a
newline only and omitting the semicolon.
Lets declare a hello function:
$ hello (){ echo 'hello';echo 'world';}
and now see how it is expanded like this with:
$ 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.
It would be nice if there was the last semicolon added even if optional,
same as it is added between both echo statements.
Some way to expand function source as a compact one-line form would be
nice as well. Could be a shopt switch or a declare switch. I'd be in
favour of a shopt switch though as declare is already clogged with many
different options.
This shopt switch could also control the verbosity/indentation for both
the output of declare -p and declare -f
--
Léa Gris