I can type alias to show a list of all the aliases.
But for functions, all I can do is grep my .bash_profile.
That only gets the ones in that fi
(because this question was marked as a duplicate of this one)
If you have functions exported in your shell a called script will see them. But luckily, they get marked as such.
#!/bin/bash
foo(){ :;}; bar(){ :;}; baz(){ :;}; export -f foo bar
export -pf
bash -c $'spam(){ :;}; \
echo "RAW:"; \
declare -pF; \
echo "FILTERED:"; \
declare -pF | awk \'$2 !~ /x/{print$3}\''
/tmp $ foo(){ :;}; bar(){ :;}; baz(){ :;}; export -f foo bar
/tmp $ export -pf
bar ()
{
:
}
declare -fx bar
foo ()
{
:
}
declare -fx foo
/tmp $ bash -c $'spam(){ :;}; echo "RAW:"; declare -pF; echo "FILTERED:"; declare -pF | awk \'$2 !~ /x/{print$3}\''
RAW:
declare -fx bar
declare -fx foo
declare -f spam
FILTERED:
spam