Forcing /bin/sh in a script under V/386 3.2 Korn shell

Alexis Porras ap at cbnews.ATT.COM
Wed Jul 26 07:21:05 AEST 1989


In article <9065 at chinet.chi.il.us> kdb at chinet.chi.il.us (Karl Botts) writes:
|
|Well, let me take a shot: put the following line as the first of any script
|you want to run only under ksh, not sh:
|
|2>/dev/null PPID=0 && { echo "$0: korn shell script" 1>&2; exit 1; }
|
 ... more stuff ...
|In fact, there is nothing that ksh can do that sh can't which can be
|a bulletproof test, because ksh is supposed to be a superset of sh, and
 ... more stuff ...
|
|What is needed is something which sh can do that ksh can't.  So far as I
 ... more stuff ...
|I will be delighted if someone can improve on this miserable kludge.

I wasn't going to do it but...put this at the top of your ksh script:

	echo ^false >/dev/null || exec ksh $0 "$@"

(or replace "ksh" by a full path name is ksh is not in the
standard PATH)

Well, that's my contribution to humanity for the week!



More information about the Comp.sys.att mailing list