2

This question already has an answer here:

The shell script snippet is given below

if [[ $OS == Linux ]] ; then

    LINUX_FC=gfortran
#
#   set 32 or 64 Bits executable
#
    ARCH=`uname -m`
    echo "PROCESSOR IS: $ARCH"
    if [ [ $ARCH == x86_64 ] ]  ; then
        BITS=SIXTYFOUR;
    else
        BITS=THIRTYTWO;
    fi

elif [[ $OS == Darwin ]] ; then

        DARWIN_FC=gfortran;

else
    BITS=THIRTYTWO;
fi;

Error is

OPERATING SYSTEM IS: Linux
: command not found
jobcomp1: line 34: syntax error near unexpected token `elif'
'obcomp1: line 34: `elif [ [ $OS == Darwin ] ] ; then

marked as duplicate by Gilles bash Aug 20 '16 at 23:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • ShellCheck is your friend. – Kusalananda Aug 20 '16 at 21:05
  • When you edit shell scripts under Windows, make sure to use Unix line endings. – Gilles Aug 20 '16 at 23:13
3

The shell really does not like those blanks between the brackets:

if [ [ $ARCH == x86_64 ] ]  ; then

It expects something like

if [[ $ARCH == x86_64 ]]  ; then

or (better)

if [ $ARCH = x86_64 ]  ; then

(there is no point in making a script bash-specific, so the == becomes = as well).

  • 2
    You should write: if [ "$ARCH" = x86_64 ] ; then. Quote your expansions. Inside a [[ … ]] quoting is not a problem. – user184899 Aug 20 '16 at 21:03
  • sure: if you expect to run the script on a system without uname. But that's a different question than asked. – Thomas Dickey Aug 20 '16 at 21:05
  • Yes, that's another error, but not the one causing the messages in the question because the shell doesn't even see that command due to the other error which is the missing then (there's a then$'\r'). – Gilles Aug 20 '16 at 23:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.