Advanced Bash-Scripting Guide: An in-depth exploration of the art of shell scripting | ||
---|---|---|
Prev | Chapter 34. Miscellany | Next |
This book deals specifically with Bash scripting on a GNU/Linux system. All the same, users of sh and ksh will find much of value here.
As it happens, many of the various shells and scripting languages seem to be converging toward the POSIX 1003.2 standard. Invoking Bash with the --posix option or inserting a set -o posix at the head of a script causes Bash to conform very closely to this standard. Another alternative is to use a
1 #!/bin/sh |
1 #!/bin/bash |
Most Bash scripts will run as-is under ksh, and vice-versa, since Chet Ramey has been busily porting ksh features to the latest versions of Bash.
On a commercial UNIX machine, scripts using GNU-specific features of standard commands may not work. This has become less of a problem in the last few years, as the GNU utilities have pretty much displaced their proprietary counterparts even on "big-iron" UNIX. Caldera's release of the source to many of the original UNIX utilities has accelerated the trend.
Bash has certain features that the traditional Bourne shell lacks. Among these are:
Certain extended invocation options
Command substitution using $( ) notation
Certain string manipulation operations
Bash-specific builtins
See the Bash F.A.Q. for a complete listing.