Bruce Gust
asked on
Unexpected "then" in shell script. How do I fix it?
Here's my error:
bsmart_1 | ./bin/start.sh: 9: ./bin/start.sh: Syntax error: "fi" unexpected (expecting "then")
Here's the code:
#!/usr/bin/env bash
if [ "$NODE_ENV" = "production" ]; then
node index.js
else
./bin/create-test-user
./bin/create-f5500
nodemon index.js --legacy-watch --ext js,mjs,json,twig
fi
No experience at all with shell scripts, so I'm not even sure where to begin.
What's wrong and how do I fix it?
Thanks!
bsmart_1 | ./bin/start.sh: 9: ./bin/start.sh: Syntax error: "fi" unexpected (expecting "then")
Here's the code:
#!/usr/bin/env bash
if [ "$NODE_ENV" = "production" ]; then
node index.js
else
./bin/create-test-user
./bin/create-f5500
nodemon index.js --legacy-watch --ext js,mjs,json,twig
fi
No experience at all with shell scripts, so I'm not even sure where to begin.
What's wrong and how do I fix it?
Thanks!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Gentlemen!
This problem has taken a little bit of a different turn.
The scripting isn't the problem, as that's not something I'm tasked with creating or fixing. The real problem is eliminating it from my Git index. Try as I might, it keeps surfacing as an "unadded' change, and then I get into permissions and it's a mess.
For the sake of courtesy, I'm going to wrap up this question, but if you would like to weigh in on what amounts to a Git issue, here's the question:
https://www.experts-exchan ge.com/que stions/291 80493/How- can-I-get- rid-of-thi s-file-tha t-I-don't- have-permi ssions-for .html#ques tionAdd
Thanks!
This problem has taken a little bit of a different turn.
The scripting isn't the problem, as that's not something I'm tasked with creating or fixing. The real problem is eliminating it from my Git index. Try as I might, it keeps surfacing as an "unadded' change, and then I get into permissions and it's a mess.
For the sake of courtesy, I'm going to wrap up this question, but if you would like to weigh in on what amounts to a Git issue, here's the question:
https://www.experts-exchan
Thanks!
ASKER
That would've been awesome, but it didn't work.
There may be more to this, however. Let me show you everything that I'm getting on my Command Line:
bsmart_1 | yarn run v1.19.1
bsmart_1 | $ sh ./bin/start.sh
: not found ./bin/start.sh: 2: ./bin/start.sh:
bsmart_1 | ./bin/start.sh: 10: ./bin/start.sh: Syntax error: "fi" unexpected (expecting "then")
bsmart_1 | error Command failed with exit code 2.
bsmart_1 | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
bsmart_bsmart_1 exited with code 2
Stopping bsmart_mongo_1 ... done
Aborting on container exit...
Not sure if : not found ./bin/start.sh: 2: ./bin/start.sh: is relevant, but I wanted to be sure to include that in case that makes a difference.