Use KORNSHELL variable instead of /bin/ksh

This patch removes instances of hardcoded
invocation of /bin/ksh and allows to
replace it with, for, example,
/usr/local/bin/ksh93

Also "ksh93" is accepted whenever "ksh" is.

Tested using the following /bin/ksh:

----8<----
WHAT=`ps -o command= -p $PPID`
msg="Something tried to call /bin/ksh: $PPID: $WHAT"
print -u2 "$msg"
logger user.warn "$msg"
exit 99
----8<----
(Warning: first two lines are FreeBSD specific)

Scripts from Makefiles should now be executed either
with

$(KORNSHELL) korn-shell-script

or

$(SHELL) bourne-shell-script

therefore #!/bin/ksh has not been changed everywhere.

/usr/dt/bin/ scripts have been converted (e.g. Xsession)

Whenever possible Imake and CPP facilities have been used.

For C and C++ programs KORNSHELL needs to be defined to
"/path/to/your/ksh" (with quotes) so that it can make
a valid C constant.

Therefore, when adding KORNSHELL to Imakefile for C files,
you have to add

CXXEXTRA_DEFINES = -DKORNSHELL=\"$(KORNSHELL)\"

or similar (for example, see programs/dtprintinfo)

But for simple shell script substitution we usually change

 LOCAL_CPP_DEFINES = -DCDE_CONFIGURATION_TOP=$(CDE_CONFIGURATION_TOP) \
                     -DCDE_INSTALLATION_TOP=$(CDE_INSTALLATION_TOP) \
                     -DCDE_LOGFILES_TOP=$(CDE_LOGFILES_TOP)

to:

 LOCAL_CPP_DEFINES = -DCDE_CONFIGURATION_TOP=$(CDE_CONFIGURATION_TOP) \
                     -DCDE_INSTALLATION_TOP=$(CDE_INSTALLATION_TOP) \
                     -DCDE_LOGFILES_TOP=$(CDE_LOGFILES_TOP) \
                     -DKORNSHELL=$(KORNSHELL) \
                     -DXPROJECTROOT=X11ProjectRoot

since we don't want quotes for shell scripts.
This commit is contained in:
Marcin Cieslak
2012-08-23 17:49:26 +02:00
committed by Jon Trulson
parent 98b17d3551
commit 17a33f0430
32 changed files with 63 additions and 40 deletions

View File

@@ -1,4 +1,4 @@
XCOMM! /bin/ksh
XCOMM! KORNSHELL
XCOMM ##########################################################################
XCOMM
XCOMM Xsession
@@ -422,7 +422,7 @@ XCOMM ##########################################################################
HASH source the .dtprofile.
HASH
if [ -f $HOME/$DTPROFILE ]; then
dtprofile_errors=`/bin/ksh -n $HOME/$DTPROFILE 2>&1`
dtprofile_errors=`KORNSHELL -n $HOME/$DTPROFILE 2>&1`
if [ "0" = "$?" ]; then
Log "sourcing $HOME/$DTPROFILE..."
. $HOME/$DTPROFILE
@@ -512,7 +512,7 @@ StartFirst()
if [ "$DTSOURCEPROFILE" = "true" ]
then
case ${SHELL##*/} in
sh | ksh | dtksh) shellprofile="$HOME/.profile";;
sh | ksh | ksh93 | dtksh) shellprofile="$HOME/.profile";;
bash) shellprofile="$HOME/.bash_profile";;
csh | tcsh) shellprofile="$HOME/.login";;
*) Log "non-standard shell $SHELL"
@@ -553,7 +553,7 @@ StartFirst()
case ${SHELL##*/} in
sh | bash | ksh | dtksh)
sh | bash | ksh | ksh93 | dtksh)
dotprofile_errors=`$SHELL -n $shellprofile 2>&1`
if [ "0" = "$?" ]; then
source_profile=". $shellprofile"
@@ -589,7 +589,7 @@ StartFirst()
PATH=/usr/dt/bin:\$PATH $tooltalk; \
$startup > $dtstart_sessionlogfile 2>&1" ;;
ksh | dtksh) $SHELL -c "$source_profile; \
ksh | ksh93 | dtksh) $SHELL -c "$source_profile; \
unset DT; \
$dtdbcache; \
PATH=/usr/dt/bin:\$PATH $tooltalk;\