4

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?

1 Answer 1

6

Solution:

Put double quotes around variable.

test.ksh

#! /usr/bin/ksh if [ "${fooVariable}" = "" ]; then fooVariable="fooString" fi echo "${fooVariable}" 

Output:

@:/tmp #./test.ksh fooString 
Sign up to request clarification or add additional context in comments.

1 Comment

Also you can use the special syntax that ksh provides for setting default values. var1_with_default=${var1:=bar}; echo $var1_with_default

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.