I wrote a shell script that checks the command line arguments for the "-i" flag.
I designed it to run from inside my gui application.
I tested my script from the terminal and it runs perfectly, does just what I want and expect. So I ran my gui (which needs superuser) and my gui would not run correctly. So I ran my gui from the terminal to see its output and saw a plethora of errors from my script (output at bottom of post).
I couldn't find a problem with my script, so I tried breaking it down to diagnose the problem. I found that when I ran my script as superuser it returned errors. So I tried just running the error line of my script as superuser and it returned the same error. And I can not figure out why.
The problem line is:
if [ "$x" == "-i" ]
To reproduce the error, run:
[ "-i" == "-i" ] ; echo $?
and
sudo [ "-i" == "-i" ] ; echo $?
the second will produce an error.
[: 34: ==: unexpected operator
[: 34: -i: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: -i: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
[: 34: ==: unexpected operator
I just cant figure it out