KornShell Error 0403-004 Specify a parameter with this command

10,523

Solution:

Put double quotes around variable.

test.ksh

#! /usr/bin/ksh

if [ "${fooVariable}" = "" ]; then
    fooVariable="fooString"
fi

echo "${fooVariable}"

Output:

@:/tmp #./test.ksh
fooString
Share:
10,523
javaPlease42
Author by

javaPlease42

// TODO Auto-generated method stub

Updated on August 21, 2022

Comments

  • javaPlease42
    javaPlease42 over 1 year

    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?

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