[Leaplist] Advanced Bash Scripting Guide (ABSG)
Jesse Goerz
jgoerz at cfl.rr.com
Thu Oct 9 20:25:09 EDT 2008
On Thu, 2008-10-09 at 07:48 -0700, Bryan J. Smith wrote:
> As always, if you want to really get into using the CLI,
> the Advanced Bash Scripting Guide (ABSG) is a good start:
> http://tldp.org/LDP/abs/html/
>
> I've found irregularities between bash 2.05, 3.0 and 3.1,
> although bash 3.1 should do everything the ABSG covers
> (including handling spaces in filenames in a for loop
> expansion proper). Just a note in case you run into issues.
>
> For those of us that deal with AIX, HP/UX and select others
> that ship ksh as their default, it helps to write more
> "pure" POSIX Bourne shell (sh) for portability, and not use
> bash or ksh extensions. Of course, even POSIX sh varies from
> legacy AT&T sh at times, so your mileage will vary.
>
You can also do feature tests to ensure your programs do what you
expect. It might be tougher with actual shell builtins...
##
#
# awk availability and feature tests
#
##
#AWK="nawk"
#if ! [ -x "\$(which \${AWK})" ]; then
# echo "ERROR: Can't find \${AWK} in your path (or not executable)"
# exit
#fi
#AWK_TEST="\$(\${AWK} '{if(match(\$0,/.*/)) {exit}}' /dev/null 2>&1)"
#if ! [ -z "\$AWK_TEST" ]; then
# echo "ERROR: Your version of \${AWK} does not support match(s,r)."
# echo "ERROR: Try setting global var \\\$AWK to nawk, gawk, or mawk?"
# exit
#fi
#AWK_TEST="\$(\${AWK} '{if(split(\$0,junk,/.*/)) {exit}}' /dev/null
2>&1)"
#if ! [ -z "\$AWK_TEST" ]; then
# echo "ERROR: Your version of \${AWK} does not support split(s,A,r)."
# echo "ERROR: Try setting global var \\\$AWK to nawk, gawk, or mawk?"
# exit
#fi
Jesse
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the Leaplist
mailing list