|
From: <pl...@pi...> - 2014-03-02 03:13:27
|
Hi,
I'm trying to get a status result back from a system call but am getting
inconsistent behaviour from the automatic typecasting magic.
bash$ test=OK;echo $test; echo $?
OK
0
gnuplot
Version 4.7 patchlevel 0 last modified 2012-10-16
....
gnuplot> cmd="test=OK;echo $test; echo $?;"
gnuplot> res=0;print system (cmd);print res
OK
0
0
gnuplot> res=0; res= system (cmd);print res
OK
0
gnuplot> res=0; if (res==0) {print "test OK"}
test OK
gnuplot> res=0; res=res+ system (cmd);print res
Non-numeric string found where a numeric expression was expected
gnuplot> res=0; res=res || system (cmd);print res
non-integer passed to boolean operator
Now I know automatic typing is _supposed_ to be inconsistent ( it's a
feature not a bug). but this seems nonsensical.
The first and second invocations are as expected and prints integer zero
(the status result returned by the shell). So what the heck is it
complaining about when I try to add integer zero to integer zero?
How is it that it manages to print the zero result directly but when I
try to add it , it suddenly becomes a "non numeric" expression? Then a
"non integer".
Is this really what it's supposed to be doing?
Best regards. Peter.
|