1

This should be pretty straightforward, but am not sure what it is complaining about.

type=${1-"-Debug"};
version=${2-"-0"};
echo "We are going to be building eValuate in build mode: " $type
if [[ $version = -1 ]]
  then
  echo "We are going to be building eValuate with omniORB-4.1.4"
  else
  echo "We are going to be building eValuate with omniORB-4.0.4"
fi
if [ $PLATFORM = "HPUX" ]
then
    if [ $type = -release ]
    then
      export MAKEFILE_MAIN=$PWD/common/makefile/makefile.hp
      export MAKEFILE_DEFS=$PWD/common/makefile/makefile.hp.rls
      shift
    else
      export MAKEFILE_MAIN=$PWD/common/makefile/makefile.hp
      export MAKEFILE_DEFS=$MAKEFILE_MAIN
    fi

    elif [ $PLATFORM = "AIX" ]
    then
       mv $PWD/Calculations/CalculationSTD/makefileAIX $PWD/Calculations/CalculationSTD/makefile
       mv $PWD/Calculations/CalculationSTD/StandardCalculationAIX.cpp     $PWD/Calculations/CalculationSTD/StandardCalculation.cpp
       rm -r $PWD/Calculations/CalculationSTD/Carleton
       if [ $type = -release ]
       then
         export MAKEFILE_MAIN=$PWD/common/makefile/makefile.aix
         export MAKEFILE_DEFS=$PWD/common/makefile/makefile.aix.rls
         shift
      else
     export MAKEFILE_MAIN=$PWD/common/makefile/makefile.aix
     export MAKEFILE_DEFS=$MAKEFILE_MAIN
      fi
  fi

This seems to work fine on Solaris and AIX, but on Linux, I get this error messages:

   : command not found 1:
   : command not found 2:
   We are going to be building eValuate in build mode:  -release
   ./setpath.sh1: line 22: syntax error near unexpected token `elif'
   '/setpath.sh1: line 22: `       elif [ $PLATFORM = "AIX" ]

Why does it not like the elif? Or, is it complaining about something else?

roymustang86
  • 8,054
  • 22
  • 70
  • 101
  • Does the script have a proper shebang line? If not, does adding `#!/bin/sh` at the beginning help? (Though your syntax is not proper Bourne shell. All the more reason to explicitly declare it as a `#!/bin/bash` script.) – tripleee Sep 10 '12 at 19:31
  • I ran the script from bash, sh, ksh prompts, but I still get the same errors – roymustang86 Sep 10 '12 at 19:33
  • Try to write "elif [ $PLATFORM = "AIX" ]" (single squeare brackets) – dimba Sep 10 '12 at 19:45
  • the code was written wrong, I have updated the code – roymustang86 Sep 10 '12 at 19:51
  • Also be consistent - or use [ cond ] or [[ cond ]]. In later you should use "==" instead of "=". – dimba Sep 10 '12 at 19:52
  • Maybe remove `el` in `elif`? At least this complaint is obvious.... – fork0 Sep 10 '12 at 20:00
  • how else will I implement multiple else if? – roymustang86 Sep 10 '12 at 20:13
  • Is `$PLATFORM` defined? If not, then `$PLATFORM` will expand to an empty string, and `elif [ $PLATFORM = "AIX" ]` will be a syntax error. You should at least change it to `elif [ "$PLATFORM" = "AIX" ]`. And your indentation is inconsistent. – Keith Thompson Sep 10 '12 at 20:23
  • *"the code was written wrong, I have updated the code"* -- Do you mean that the code you posted didn't match the code that had the problem? If so, then updating it is fine. But don't update the code in the question *to correct the problem you're asking about*; that would make the question useless. – Keith Thompson Sep 10 '12 at 20:25
  • I just copy pasted your script and it runs without any warnings. I've only replaces `[ cond ]` with `[[ cond ]]` and `=` with `-eq`. Sorry, but without being able to reproduce it, it's hard to help. – Zagorax Sep 10 '12 at 20:33

1 Answers1

1

Got the answer finally, it is thanks to something completely random, something to do with format:

I had transferred the file over from my windows machine, and I guess Linux is just a bitch that can't handle it. Solaris and AIX do just fine.

Used this command. dos2unix *.sh

roymustang86
  • 8,054
  • 22
  • 70
  • 101