Operating System - HP-UX
1833847 Members
1995 Online
110063 Solutions
New Discussion

Coming from SCO Openserver 5

 
Trevor Henke_1
New Member

Coming from SCO Openserver 5

With environment variables, SCO does not distinguish between an unset variable and one that is set to "null". They both test true as "null". In HP-UX 11.11, an unset variable cannot be tested as "null" without producing an error: "sh: var: Parameter not set.", where "var" is the variable name. The error also causes the shell script to abort. Is there a way to emulate the SCO behavior?
WasSCO
3 REPLIES 3
Patrick Wallek
Honored Contributor

Re: Coming from SCO Openserver 5

If you need a environment variable set to null, do an

# export var=

And make sure there is nothing after the equal sign, no spaces or anything.

Is this what you want? Or do you want unset to behave like SCO?

I suppose you could set up an alias so that if you do an 'unset var' it actual does an 'export var='.
John Poff
Honored Contributor

Re: Coming from SCO Openserver 5

Hi,

You can specify the 'unset' behavior by setting the 'set -o unset' flag in the posix shell (see man sh-posix). Here is a sample script that shows the behavior each way:

# cat ./unset.test

#!/bin/sh

# unset.test

set +o nounset

unset TESTVAR
echo "TESTVAR is $TESTVAR"

set -o nounset

unset TESTVAR
echo "TESTVAR is $TESTVAR"

# ./unset.test
TESTVAR is
./unset.test[13]: TESTVAR: Parameter not set.


The first way (set +o unset) should give you the behavior you are used to in SCO.


JP

P.S. I spent nearly four years working in a SCO environment. Pretty reliable stuff for what it did.


John Poff
Honored Contributor

Re: Coming from SCO Openserver 5

And of course, where I said 'set -o unset' above, I meant to say 'set -o nounset'. I need more caffeine! :)

JP