1

I would like to execute a series of commands that compile my program. But it does not seem to be working. This is my script

#!/bin/bash

task[0] = $(cd vssl/make/; make clean;)
compile[0] = $(make all)
error[0] = $(echo "We failed at vssl install")

task[1] = $(cd ../../web/make/; make clean;)
compile[1] = $(make install)
error[1] = $(echo "We failed at web install")

eval "$task[0]"
if (eval "$compile[0]"); then
    eval "$task[1]"
    if (eval "$compile[1]"); then
        echo "ALL DONE"
    else
        eval "$error[1]"
    fi
else
    eval "$error[0]"
fi

I have tried bunch of other methods, where I replace command declaration with this for example

task[0] = 'cd vssl/make/; make clean;'

This is just one error line, other lines say the same error But every time I get same errors saying

./install_everything.sh: line 4: task[0]: command not found

What exactly am I doing wrong here? I have tried simply substituting the actual command instead of variables like this

#!/bin/bash

cd vssl/make/
make clean
if(make all); then
    cd ../../web/make/
    make clean
    if(make install); then
        echo "ALL DONE"
    else
        echo "We failed at web install"
    fi
else
    echo "We failed at vssl install"
fi

And it worked perfectly. So I am quite stumped as to why my first method does not work.

1 Answer 1

3

Remove the space:

task[0] = $(cd vssl/make/; make clean;)
       ^ ^
Sign up to request clarification or add additional context in comments.

2 Comments

Oh wow, thank you so much, that has worked. What is the difference between space and no space?
@Quillion, it's the basic syntax of the shell. Commands and arguments are separated by space, so when the shell sees var = value, it's looking for the command var, passing 2 arguments to it. Variable assignment must be var=value. It hurts readability, but that's the way it is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.