Shell scripting commandsRichard Mawhttp://yakking.branchable.com/posts/scripting-commands/yakkingikiwiki2014-06-11T12:28:23ZShell builtinshttp://yakking.branchable.com/posts/scripting-commands/comment_1_091dab5fede86bd1dc58816edf550bc8/Stuart2014-06-11T12:28:23Z2014-06-11T12:28:23Z
<p>Beware that many of these commands are actually shell builtins (or more precisely, they can be both a shell builtin and also a command in /bin or /usr/bin). When you run <code>true</code> in a script, you're not running true(1) from <code>/bin/true</code>, you're running the builtin <code>true</code>. There's a performance difference there but it's not a big issue. When it comes to other commands like <code>[</code> and <code>printf</code>, there can be a big difference and you should look at <code>help [</code> rather than <code>man [</code> for documentation.</p>
<p>Use <code>type</code> to investigate what a command actually is:</p>
<pre><code> $ type -a [
[ is a shell builtin
[ is /usr/bin/[
$ type -a ls
ls is aliased to `ls -FC --color=tty'
ls is /bin/ls
$ type -a cd
cd is a function
cd ()
{
__load_dir_settings "$@";
builtin cd "$@"
}
cd is a shell builtin
</code></pre>
<p>(don't ask about that last one!)</p>