dimanche 14 avril 2019

syntax error when assigning to command result to variable

I'm doing some basic unit testing with the shunit2 unit test framework. I'm getting the error " syntax error near unexpected token `nodeError=$( node "node_fake_returns/return_error.js" )" on the first line of my function. the function is as follows:

function testHandleNodeReturnError{
    nodeError=$( node "./node_fake_returns/return_error.js" )    
    if [ grep -i "Error" <<< "$nodeError"  ]; then
        assertTrue "true"
    fi
}

It is suppose to run a node script that returns an error message to stdout, then assign that output to a variable. Only this first line in the function is important.

I'm quite new to bash and I've messed with the formatting of this line, mostly just adding spaces in different places, but I can't seem to find what's causing the syntax error. This is probably pretty simple but if somebody could show me what might be wrong I would be greatful.

Thanks!

Aucun commentaire:

Enregistrer un commentaire