sh脚本访问函数中的全局变量

时间:2016-12-02 15:00:29

标签: linux shell scripting sh

我正在写这个问题,因为我不熟悉sh脚本,但我知道以下行在/ bin / bash中工作,但我需要使用/ bin / sh。以下是代码:

#!/bin/sh

trythis=1

test()
{
  ((trythis++))
  echo $trythis
}

test

我希望2作为输出,但我得到以下错误:

./test: 7: ./test: trythis++: not found
1

0 个答案:

没有答案
相关问题