help-bash
[Top][All Lists]
Advanced

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

How to print bash function in one line?


From: Peng Yu
Subject: How to print bash function in one line?
Date: Wed, 29 May 2024 09:52:01 -0500

Hi,

Bash functions shown by declare -f may not be readily changed to one
line format.

$ declare -f f
f ()
{
    x=
}

In the above example, if I fold the output in one line, it would be
the following code, which is not valid in bash.

f () { x= }

While I could add ; manually to make it work for a specific example,
but I am not sure adding ; to each line would be a viable option. I'd
rather only add ; only when necessary.

Is there a way in bash to print a function definition in one line format?

-- 
Regards,
Peng



reply via email to

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