提取基本ARGV

时间:2018-03-22 18:03:45

标签: bash

在尝试从bash脚本中提取单个参数时,我收到错误:

./intercept.sh: line 23: [run: command not found
./intercept.sh: line 28: [run: command not found
USAGE: ./intercept.sh run|term

我如何处理所提供的论据:

function main () {
  if [$1 == 'run']
  then
    echo "turning intercept proxies on";
    # enableInterceptProxies;
    echo "intercept proxies turned on";
  elif [$1 == 'term']
  then
    echo "turning intercept proxies off";
    # disabbleInterceptProxies;
    echo "intercept proxies turned off";
  else
    usage;
  fi
}

main $@;

我在这里做错了什么?我需要做的就是检查单个参数是run还是term,我该如何成功完成?

0 个答案:

没有答案