此KornShell代码引发以下错误:
test.ksh
#! /usr/bin/ksh
if [ ${fooVariable} = "" ]; then
fooVariable="fooString"
fi
echo "${fooVariable}"
错误:
@:/tmp #./test.ksh
./test.ksh[3]: test: 0403-004 Specify a parameter with this command.
为什么要抛出这个错误,以及如何修复它?
发布于 2015-01-13 20:18:01
解决方案:
在变量周围放双引号。
test.ksh
#! /usr/bin/ksh
if [ "${fooVariable}" = "" ]; then
fooVariable="fooString"
fi
echo "${fooVariable}"
输出:
@:/tmp #./test.ksh
fooString
https://stackoverflow.com/questions/27930727
复制相似问题