Reputation: 6323
I made an upstart script which breaks my expectations entirely.
stupid-test.conf
script
VALUE="PONG"
echo "START" >> /var/log/stupid-test.log
if [ "$VALUE" == "PONG" ]; then
echo "GOOD PONG" >> /var/log/stupid-test.log
fi
if [ "$VALUE" != "PONG" ]; then
echo "BAD PONG" >> /var/log/stupid-test.log
fi
if [ "$VALUE" == "PING" ]; then
echo "BAD PING" >> /var/log/stupid-test.log
fi
if [ "$VALUE" != "PING" ]; then
echo "GOOD PING" >> /var/log/stupid-test.log
fi
echo >> /var/log/stupid-test.log
end script
stupid-test.log
START
GOOD PING
Naturally, if you execute the exact same commands in bash, it works perfectly:
START
GOOD PONG
GOOD PING
This appears to work for anything you can put in VALUE
--I've tried integers and strings.
Upvotes: 2
Views: 1723
Reputation: 781731
Use =
rather than ==
when performing equality tests. ==
is a bash extension, and it's not available in the shell that upstart
runs. Upstart runs all scripts using /bin/sh -e
. On Ubuntu systems, /bin/sh
is dash
, not bash
.
Upvotes: 5