Reputation: 4963
This KornShell code is throwing the following error:
test.ksh
#! /usr/bin/ksh
if [ ${fooVariable} = "" ]; then
fooVariable="fooString"
fi
echo "${fooVariable}"
Error:
@:/tmp #./test.ksh
./test.ksh[3]: test: 0403-004 Specify a parameter with this command.
Why is this error being thrown and how to fix it?
Upvotes: 4
Views: 12098
Reputation: 4963
Solution:
Put double quotes around variable.
test.ksh
#! /usr/bin/ksh
if [ "${fooVariable}" = "" ]; then
fooVariable="fooString"
fi
echo "${fooVariable}"
Output:
@:/tmp #./test.ksh
fooString
Upvotes: 6