gpt4 book ai didi

shell - KornShell 错误 0403-004 使用此命令指定参数

转载 作者:行者123 更新时间:2023-12-03 21:34:26 28 4
gpt4 key购买 nike

此 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.

为什么会抛出此错误以及如何修复它?

最佳答案

解决方案:

在变量周围加上双引号。

test.ksh

#! /usr/bin/ksh

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

echo "${fooVariable}"

输出:
@:/tmp #./test.ksh
fooString

关于shell - KornShell 错误 0403-004 使用此命令指定参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27930727/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com