I was discussing with my friend on how the commands are parsed in the shell, and he told me that bash searches the command in following order
- List of aliases
- List of shell keywords
- List of user defined functions
- List of shell built in functions
- List of directories specified in the PATH variable , from left to right.
I know aliases can be found by issuing the alias
command. PATH variable contents can be found using echo $PATH
command.
Can you please tell me which commands do I need to use ?
- To list all shell keywords
- To list all user defined functions
- To list of shell built in functions
Best Answer
In Bash:
man bash | grep -10 RESERVED
lists reserved words:declare -F
andtypeset -F
shows function names without their contents.enable
lists builtin shell commands (I don't think these are functions as such).So doesman builtins