xpg4_sh(1) xpg4_sh(1)
NAME
xpg4sh - XPG4 shell
SYNTAX
/sbin/xpg4/sh [option ...] [file] [argument ...]
DESCRIPTION
The XPG4 shell is practically identical to the Korn shell [see
ksh(1)]. However, since the Korn shell does not fulfill all the condi-
tions specified by X/Open (see the CAE Specification, Commands and
Utilities, Issue 4), a shell is also supplied under /sbin/xpg4/sh,
which satisfies the remaining XPG4 conditions (X/Open Branding).
The ksh Korn shell was not fully adapted to XPG4 because, in many
cases, it should behave more like the sh Bourne shell. To prevent the
behavior of the Korn shell from being incompatible with its previous
behavior in such cases, the changes were carried out separately for a
special XPG4 shell.
The default shell (/sbin/sh) is currently linked to the Bourne shell
(/sbin/bourne/sh). If you wish to have the XPG4 shell as the default
shell, you need to set up the link to /sbin/xpg4/sh.
Differences between the Korn shell and the XPG4 shell
1. If you do not enter anything after the -o option when calling the
shell, the XPG4 shell sends the following message to standard
error: ksh: '': bad option(s).
The Korn shell, however, sends the permitted options to standard
output.
2. In the Korn shell, time is a keyword at the start of a line (like
if, then etc.; cf. ksh(1), section Reserved words). In the XPG4
shell (as with the Bourne shell), on the other hand, time is a
standard user command (/usr/bin). The following deviations regard-
ing time can be distinguished.
The behavior of the
time pipeline
command varies. In the case of the Korn shell, the pipeline com-
mands are executed and then the elapsed time, the user and system
time for these commands are reported as statistics to standard
error.
With the XPG4 shell, time is only executed for the first pipeline
command and the statistics are output beforehand.
Page 1 Reliant UNIX 5.44 Printed 11/98
xpg4_sh(1) xpg4_sh(1)
Thus in the case of the Korn shell, if you issue the
time ls | pg
call, you will first see the output of ls and the pg input must
then be performed. It is only when everything has ended that the
statistics are output for ls and pg.
With the XPG4 shell, the statistics are output first, followed by
the output of ls and the input for pg.
3. With the Korn shell, an error message is output if the echo command
cannot write when writing to a file because the disk is full. The
end status in this case is 1. The XPG4 shell ignores this error.
4. The Korn shell does not lose any parameters in the following
getopts command if the shell script is called with, for example, -l
abc. When echo $* is called for the second time, the XPG4 shell
only outputs -l instead of -l abc:
#!/sbin/ksh
set -x
echo $*
while getopts :l:u:t: arguments
do
case $arguments in
l) ;;
u) ;;
t) ;;
*) echo "wrong option \n"
exit 1
;;
esac
done
echo $*
5. If an attempt is made with a read-only variable (typeset -r) to
change the value, the Korn and XPG4 shells return the error message
" ...: is read only".
The difference between the two shell responses is that with the
XPG4 shell, the error message is deliberately generated later.
6. The Korn shell supplies the function name for a shell script func-
tion in $0 while the XPG4 shell also supplies the name of the shell
script.
Page 2 Reliant UNIX 5.44 Printed 11/98
xpg4_sh(1) xpg4_sh(1)
For example, in the following shell script called test.sh:
typeset -fux dummy
function dummy
{
echo $0
}
dummy
The Korn shell echoes dummy, the XPG4 shell echoes test.sh.
SEE ALSO
ksh(1), sh(1).
Page 3 Reliant UNIX 5.44 Printed 11/98