Reputation: 1303
I have the following function in bash, who was previously in the case part of a switch, but no matter where I put it I always get a syntax error
do_start(){
if[f $PIDFILE]; then
echo "supervisord already running: $PIDFILE" exit 1
fi
log_begin_msg "Starting Supervisor daemon manager..."
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $SUPERVISORD -- $OPTS || log_end_msg 1
log_end_msg 0
}
and I get:
runScript.sh: Syntax error: "then" unexpected (expecting "}")
I don't know what is going on please help
Upvotes: 1
Views: 87
Reputation: 785896
Spaces around [ and ]
are needed and I think you meant -f
to check if this is a file.
You need to replace:
if[f $PIDFILE];
by:
if [ -f "$PIDFILE" ];
OR better (since you're using BASH)
if [[ -f "$PIDFILE" ]];
Upvotes: 2