0

I have a script that is running on Redhat 5.11 machine with a type of SHELL pdksh.

However, when I run the same script on Redhat 7.1 with the KSH93 shell it gives me the following error:

./script.ksh[212]: set: posix: bad option(s) Usage: set [-sabefhkmnprtuvxBCGH] [-A name] [-o[option]] [arg ...]

Here is the line that generates the error:

set -o posix
codeforester
  • 39,467
  • 16
  • 112
  • 140
user3535890
  • 13
  • 1
  • 6
  • You may be able to achieve posix mode in Korn shell by running: `export POSIXLY_CORRECT=YES` before you start your script. The same behaviour of rejecting `set -o posix` is present on the ksh that is on Ubuntu 16.04, but I can see that posix behaviour is enabled by setting the above environment variable first. – mao Aug 08 '17 at 08:58
  • I launched your command, however I still have the same error message – user3535890 Aug 08 '17 at 09:07
  • If your intention is to enable posix behaviour in your shell script then instead of using the `set -o posix` inside your script, you could either export POSIXLY_CORRECT in your environment before running your script or include the line below inside your script and remove the 'set -o posix': `[[ -z ${POSIXLY_CORRECT:=""} ]] && export POSIXLY_CORRECT=YES` – mao Aug 08 '17 at 09:28

0 Answers0