Installation guide
One significant difference between the ULTRIX sh5 shell and the DIGITAL
UNIX sh shell is in their treatment of positional parameters when a
function is called. The DIGITAL UNIX sh shell sets the positional
parameters to the function call’s arguments as does the ULTRIX sh5 shell.
However, the DIGITAL UNIX sh shell also saves the values the positional
parameters held before the function was called. Upon return from the
function, the shell sets the positional parameters to the saved values. The
ULTRIX sh5 shell does not restore the positional parameters in this way; it
leaves them set to the values they hold when the function returns. If your
scripts do not rely on the ULTRIX behavior, this difference is transparent.
The most efficient way to modify the first line in a number of sh5 scripts is
to write a shell script. Example 3–1 shows a shell script that changes the
first line in sh5 scripts.
Example 3–1: Shell Script to Convert sh5 Scripts into sh Scripts
#! /bin/sh
trap ’rm -f /tmp/conv$$ ; exit ’012
1
for i 2
do
sed ’ls/bin\/sh5/bin\/sh/’ $i > /tmp/conv$$
3
[ -f /tmp/conv$$ ] && { 4
mv /tmp/conv$$ $i 5
}
done
1 The trap command makes the shell recognize the 0, 1, or 2 signals. If
the shell receives one of these signals, it removes the file
/tmp/conv
$$
, where
$$
is the process number of the current process.
The shell script uses this file during its processing.
Once the /tmp/conv
$$
file is removed, the shell script exits.
2 The for command starts a loop that continues as long as there are
arguments on the shell script command line. Therefore, if you invoke
this shell script with three arguments, the loop executes three times.
The loop executes the commands between do and done.
3 The sed command modifies the first line of its input. The command
searches for the string bin/sh5 and replaces it with the string
bin/sh. The sed command writes its output to the /tmp/conv
$$
file.
4 The command in brackets ([]) tests to see that the /tmp/conv
$$
file
exists and has a size greater than zero.
The brackets are an alias for the /usr/bin/test command.
Migrating Your ULTRIX User Environment to a DIGITAL UNIX System 3–7