env
displays a list of all environment variables
$ env |wc -l
63
Total environment variables = 63
According to help export
-p display a list of all exported variables and functions
$export -p |wc -l
63
Environment variables+lines of functions=63 then lines of functions=0
set
disply a list of environment variables+ shell variables+functions
$set |wc -l
4772
Then for showing only variables(environment variables+shell variables)
$(set -o posix ;set)|wc -l
172
It means lines of functions= 4772-172 not zero please explain to me what's happening?
The confusion arises from the fact that
export -p
by default only shows exported variables (declare -x
), not functions.To display the exported functions (
declare -fx
) usingexport
:Also just to clarify, counting number of lines to get number of functions is completely wrong as function definitions span multiple lines (even if it defined in a single line while declaring,
set
shows them in multiple lines).