bash errorif: Expression Syntax

Chris F.A. Johnson cfaj-uVmiyxGBW52XDw4h08c5KA at public.gmane.org
Sat Dec 10 15:23:05 UTC 2005


On Sat, 10 Dec 2005, J. Qiang Li wrote:

> hello, all
>
> i have a simple bash script that giving me problem under solaris.
>
> run "source my_script", got error: "if: Expression Syntax"
>
> then i chmod +x on my_script and invoke it with ./my_script , it worked. why? i am including this
> script as postinstall in a solaris package, it failed to get invoked at the postinstall stage. how
> do i fix that?
>
> it's a simple script as
>
> #!/bin/sh
> if [ -e 'file' ]; then
>  echo "something"
> fi

    That is not a bash script. On Solaris, /bin/sh is not bash, it is a
    Bourne shell. Bourne shells do not have the -e operand.

    Either use [ -f 'file' ] or change the shebang to point to bash.

-- 
    Chris F.A. Johnson                      <http://cfaj.freeshell.org>
    ===================================================================
    Author:
    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list