Background
I recently worked a problem in a previous post where it wasn’t clear which version of the command nohup was getting used. The version that was built into the C-shell interpreter, or the executable sitting under /usr/bin/nohup. This brought up an interesting point, how do you know what commands are builtins to the shell itself?
Enter the commands: builtins and enable
These are 2 commands that I’d never even heard of until I started doing research for this post. They both basically do the same thing. They show you all the builtin commands for a particular shell, builtins for C-shell, and enable for Bourne Shell.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# C-shell builtins #NOTE: run this command within a C-shell (aka. csh or tcsh) % csh % builtins : @ alias alloc bg bindkey break breaksw builtins case cd chdir complete continue default dirs echo echotc else end endif endsw eval exec exit fg filetest foreach glob goto hashstat history hup if jobs kill limit log login logout ls-F nice nohup notify onintr popd printenv pushd rehash repeat sched set setenv settc setty shift source stop suspend switch telltc termname time umask unalias uncomplete unhash unlimit unset unsetenv wait where which while |
1 2 3 4 5 6 7 |
# Bourne Again Shell builtins #NOTE: run this command within Bourne Again Shell (aka. bash) % bash % enable | cut -d" " -f2 | sed -e :a -e '$!N;s/\n/ /;ta' . : [ alias bg bind break builtin caller cd command compgen complete continue declare dirs disown echo enable eval exec exit export false fc fg getopts hash help history jobs kill let local logout popd printf pushd pwd read readonly return set shift shopt source suspend test times trap true type typeset ulimit umask unalias unset wait |
NOTE: The command is enable. I’m simply running the output of enable through this cut & sed filter so that the output of enable is more concise for this example.
nohup
As you can see, by looking at the output from builtins, the command nohup is listed there, which means that C-shell has it’s own implementation of nohup. Looking at the output from enable, you can see that Bourne Shell, doesn’t include it’s own builtin for nohup, so it would use /usr/bin/nohup. Pretty simple, eh?
NOTE: For further details regarding my one-liner blog posts, check out my one-liner style guide primer.