Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

  1. List of aliases
  2. List of shell keywords
  3. List of user defined functions
  4. List of shell built in functions
  5. 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

  1. list all shell keywords
  2. list all user defined functions
  3. list all shell built in functions

Thanks.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

list all shell keywords

Consult your shell's manual for that. "Keyword" is a little ambiguous—for Bash, see the defined builtins below, or consider looking at the shell variables, special parameters, or the index of shell reserved words.

list all user defined functions

In Bash (and Zsh, and probably others), you can use typeset -f to list all functions.

list all shell built in functions

The Bash Reference Manual gives you a list of:

In OS X you can also check out the manpage at man builtin for a comparison between builtins available in different shells. I'm not sure if this is available in GNU/Linux.

share|improve this answer
    
+1.Thanks for elaboration. I checked and man builtins worked in GNU/Linux/. Also from other post I found that man bash | grep -10 RESERVED and enable are useful for reserved words and builtins respectively. –  CppLearner Feb 1 '13 at 21:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.