gpt4 book ai didi

linux - 我该怎么做才能修复案例中的错误?

转载 作者:太空宇宙 更新时间:2023-11-04 10:23:17 27 4
gpt4 key购买 nike

我的代码是:

-cname)
changeName="{2}"

if [ -z $changeName ]; then
echo -en "Which note name do you want to change?"
read -r $changeName
echo "What would you like to change the name to?"
read -r changeNewName
if ! [ -z "${3}" ]; then
echo "The name has to have no spaces."
exit 1
fi
if [ -f /usr/share/cnote/notes/$changeNewName ]; then
echo "That note name is already used. Please choose a new one."
exit 1
fi
cp "/usr/share/cnote/notes/${changeName}" "/usr/share/cnote/notes/${changeNewName}"
;;

如果我删除我的 case 语句的这一部分,它会再次工作,但是对于那部分我会得到这个错误:root@minibian:~/cnote# ./cnote -cname./cnote: 第 73 行:意外标记附近的语法错误 ;;'
./cnote: 第 73 行:
;;'

最佳答案

您的第一个 if block 没有关闭。并且您不应将 $ 符号放在 changeName 之前。所以第一部分一定是

if [ -z $changeName ]; then
echo -en "Which note name do you want to change?"
read -r changeName
echo "What would you like to change the name to?"
read -r changeNewName
fi

关于linux - 我该怎么做才能修复案例中的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42888337/

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