[Top][All Lists]

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

Request change to output of declare -f funcname

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


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

reply via email to

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