recent test -e ksh incompatibility in hpux?

On a very new (11.31) hpux machine, I can no longer execute shell fragements like:

if [ -e .profile.foo ] ; then
. .profile.foo
fi

and get "ksh: test: argument expected"

if I convert this to -d or -f as appropriate (which I've not had to do on older versions of hpux (11.23) nor any other unix platform I've tried (aix, linux, sun)).

Is -e something that is considered a non-portable ksh construct?

I thought ksh used built in test -- try bash, it has it! My hpux (old) man test has no -e, -e fails like that. But /bin/test likes it! sh -c likes it!

The shell message is from test, and yes this is probably the builtin. Regardless, the question remains. I've not had any such problem with ksh on other Unixes, nor the older hpux versions.

The suggestion to use bash is not very helpful, since it's not installed on this machine.

It is easy to get from the uk hp binary archive. Porting And Archive Centre For HP-UX
ksh93 looks OK. try dtksh from the CDE dir, it's ksh93+.

I'm not positive that it's actually using the test built-in. On some shells [ ] isn't a built in while [[ ]] is. What if you use [[ ]]?

The [ ] is the official form supported by posix and -e is supposed to work. So the test is standard and portable. Something is broken on your new system. I would check with HP to see if a patch exists.

Google is your friend: IT Resource Center forums - -e option not working in ksh!!!! - This thread has been closed

This actually depends on what version of ksh you're using.
The -e operand (which is now POSIX) wasn't available in older versions
of ksh88.

On some versions of HP-UX the ksh provided as /usr/bin/ksh is actually an older version than the system sh, provided as /usr/bin/sh, which is actually a newer version of the Korn Shell.

Consider the following:

$ uname -sr
HP-UX B.11.11
$ /usr/bin/ksh -c '[ -e .profile ]; what /usr/bin/ksh|fgrep Ver'
/usr/bin/ksh: test: argument expected
        Version 11/16/88
$ /usr/bin/sh -c '[ -e .profile ];what /usr/bin/sh|fgrep Ver'
         Version M-11/16/88f

So in order to run your script you could simply switch from ksh to sh.

sounds like you are using ksh88 rather than ksh93.

even pdksh appears to support -e.