|Text-only||Table of Contents (frame/ no frame)|
|(6) ksh/bash vs sh|
The philosophy of separate Unix tools each performing a single operation was followed closely by the designers of the original shell, so it had very few internal commands and used external tools for very trivial operations (like
[). Ksh and bash internally performs many of the basic string and numeric manipulations and conditional tests. Occasional problems arise because the internal versions of some commands like
echoare not fully compatible with the external utility they replaced.
The action taken every time a shell needs to run an external program is to locate the program (via $PATH),
fork(), which creates a second copy of the shell, adjust the standard input/output for the external program, and
exec(), which replaces the second shell with the external program. This process is computationally expensive (relatively), so when the script does something trivial many times over in a loop, it saves a lot of time if the function is handled internally.
If you follow textbooks on Bourne shell programming, all of the advice should apply no matter which of the Bourne-derived shells you use. Unfortunately, many vendors have added features over the years and achieving complete portability can be a challenge. Explicitly writing for ksh (or bash) and insisting on that shell being installed, can often be simpler.
The sh and ksh man pages use the term special command for the internal commands - handled by the shell
|ksh-vs-sh.src last modified Mar 10, 2005||Introduction||Table of Contents
|© Dartmouth College|