Upstart如果声明执行不合理

时间:2013-12-13 03:56:59

标签: bash upstart

我制作了一个完全打破我期望的新贵剧本。

笨-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

笨-test.log中

START
GOOD PING

当然,如果你在bash中执行完全相同的命令,它可以完美地运行:

START
GOOD PONG
GOOD PING

这似乎适用于你可以放入VALUE的任何内容 - 我尝试过整数和字符串。

1 个答案:

答案 0 :(得分:5)

执行相等性测试时,请使用=而不是====是一个bash扩展,它在upstart运行的shell中不可用。 Upstart runs all scripts using /bin/sh -e。在Ubuntu系统上,/bin/shdash,而不是bash