468 |
* File System Conventions:: File- and pathnames |
* File System Conventions:: File- and pathnames |
469 |
* Shell Substitutions:: Variable and command expansions |
* Shell Substitutions:: Variable and command expansions |
470 |
* Assignments:: Varying side effects of assignments |
* Assignments:: Varying side effects of assignments |
471 |
|
* Parentheses:: Parentheses in shell scripts |
472 |
* Special Shell Variables:: Variables you should not change |
* Special Shell Variables:: Variables you should not change |
473 |
* Limitations of Builtins:: Portable use of not so portable /bin/sh |
* Limitations of Builtins:: Portable use of not so portable /bin/sh |
474 |
* Limitations of Usual Tools:: Portable use of portable tools |
* Limitations of Usual Tools:: Portable use of portable tools |
9056 |
* File System Conventions:: File- and pathnames |
* File System Conventions:: File- and pathnames |
9057 |
* Shell Substitutions:: Variable and command expansions |
* Shell Substitutions:: Variable and command expansions |
9058 |
* Assignments:: Varying side effects of assignments |
* Assignments:: Varying side effects of assignments |
9059 |
|
* Parentheses:: Parentheses in shell scripts |
9060 |
* Special Shell Variables:: Variables you should not change |
* Special Shell Variables:: Variables you should not change |
9061 |
* Limitations of Builtins:: Portable use of not so portable /bin/sh |
* Limitations of Builtins:: Portable use of not so portable /bin/sh |
9062 |
* Limitations of Usual Tools:: Portable use of portable tools |
* Limitations of Usual Tools:: Portable use of portable tools |
9127 |
you use @command{bash} 2.05 or higher to execute @command{configure}, |
you use @command{bash} 2.05 or higher to execute @command{configure}, |
9128 |
you'll need to use @command{bash} 2.05 for all other build tasks as well. |
you'll need to use @command{bash} 2.05 for all other build tasks as well. |
9129 |
|
|
9130 |
@item @command{/usr/xpg4/bin/sh} on Solaris |
@item Ksh |
9131 |
|
@prindex Ksh |
9132 |
|
@prindex Korn shell |
9133 |
|
@prindex @samp{ksh88} |
9134 |
|
@prindex @samp{ksh93} |
9135 |
|
The Korn shell is compatible with the Bourne family and it mostly |
9136 |
|
conforms to @acronym{POSIX}. It has two major variants commonly |
9137 |
|
called @samp{ksh88} and @samp{ksh93}, named after the years of initial |
9138 |
|
release. It is usually called @command{ksh}, but Solaris systems have |
9139 |
|
three variants: |
9140 |
|
@prindex @command{/usr/bin/ksh} on Solaris |
9141 |
|
@command{/usr/bin/ksh} is @samp{ksh88}, |
9142 |
@prindex @command{/usr/xpg4/bin/sh} on Solaris |
@prindex @command{/usr/xpg4/bin/sh} on Solaris |
9143 |
The @acronym{POSIX}-compliant Bourne shell on a Solaris system is |
@command{/usr/xpg4/bin/sh} is a @acronym{POSIX}-compliant variant of |
9144 |
@command{/usr/xpg4/bin/sh} and is part of an extra optional package. |
@samp{ksh88}, and |
9145 |
There is no extra charge for this package, but it is also not part of a |
@prindex @command{/usr/dt/bin/dtksh} on Solaris |
9146 |
minimal OS install and therefore some folks may not have it. |
@command{/usr/dt/bin/dtksh} is @samp{ksh93}. @command{/usr/bin/ksh} |
9147 |
|
is standard on Solaris; the other variants are parts of optional |
9148 |
|
packages. There is no extra charge for these packages, but they are |
9149 |
|
not part of a minimal OS install and therefore some installations may |
9150 |
|
not have it. |
9151 |
|
@prindex @samp{pdksh} |
9152 |
|
A public-domain clone of the Korn shell called @samp{pdksh} is also |
9153 |
|
widely available: it has most of the @samp{ksh88} features along with |
9154 |
|
a few of its own. |
9155 |
|
|
9156 |
@item Zsh |
@item Zsh |
9157 |
@cindex Zsh |
@cindex Zsh |
9690 |
$ @kbd{echo $(echo blah)} |
$ @kbd{echo $(echo blah)} |
9691 |
$(echo blah) |
$(echo blah) |
9692 |
@end example |
@end example |
9693 |
|
|
9694 |
|
If you do use @samp{$(@var{commands})}, make sure that the commands |
9695 |
|
do not start with a parenthesis, as that would cause confusion with |
9696 |
|
a different notation @samp{$((@var{expression}))} that in modern |
9697 |
|
shells is an arithmetic expression not a command. To avoid the |
9698 |
|
confusion, insert a space between the two opening parentheses. |
9699 |
|
|
9700 |
@end table |
@end table |
9701 |
|
|
9702 |
|
|
9783 |
@samp{$@{@var{var}:-@var{value}@}} and @samp{$@{@var{var}=@var{value}@}} |
@samp{$@{@var{var}:-@var{value}@}} and @samp{$@{@var{var}=@var{value}@}} |
9784 |
for the rationale. |
for the rationale. |
9785 |
|
|
9786 |
|
@node Parentheses |
9787 |
|
@section Parentheses in Shell Scripts |
9788 |
|
|
9789 |
|
Beware of two opening parentheses in a row, as some shell |
9790 |
|
implementations mishandle them. For example, @samp{pdksh} 5.2.14 |
9791 |
|
misparses the following code: |
9792 |
|
|
9793 |
|
@example |
9794 |
|
if ((true) || false); then |
9795 |
|
echo ok |
9796 |
|
fi |
9797 |
|
@end example |
9798 |
|
|
9799 |
|
@noindent |
9800 |
|
To work around this problem, insert a space between the two opening |
9801 |
|
parentheses. There is a similar problem and workaround with |
9802 |
|
@samp{$((}; see @ref{Shell Substitutions}. |
9803 |
|
|
9804 |
|
@acronym{POSIX} requires support for @code{case} patterns with opening |
9805 |
|
parentheses like this: |
9806 |
|
|
9807 |
|
@example |
9808 |
|
case $filename in |
9809 |
|
(*.c) echo "C source code";; |
9810 |
|
esac |
9811 |
|
@end example |
9812 |
|
|
9813 |
|
@noindent |
9814 |
|
but the @code{(} in this example is not portable to many older Bourne |
9815 |
|
shell implementations. It can be omitted safely. |
9816 |
|
|
9817 |
@node Special Shell Variables |
@node Special Shell Variables |
9818 |
@section Special Shell Variables |
@section Special Shell Variables |