Question

I have a simple script as follows:

#!/bin/ksh

JAVA_SRC="/home/myuser/Setup\ Files/jre/bin/java"
eval $JAVA_SRC

When I run this on HP-UX, I get this error:

$ spacetest.sh
/home/myuser/Setup^BFiles/jre/bin/java:  not found

It seems like the shell cannot properly handle the escaped whitespace and is putting garbage instead of the "\ ". This works perfectly fine on other *NIX platforms. If I echo $JAVA_SRC right before the eval, the path shows fine.

Is there any way to properly handle this on HP-UX?

Était-ce utile?

La solution

The solution is to simply, as William suggested above, use quotes around the variable name ("$JAVA_SRC").

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top