gpt4 book ai didi

linux - vCard=$(echo $REPLY | cut -d'i' -f 1) 有什么问题

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

当我测试下面的代码时,我得到一个错误:

syntax error near unexpected token `)'

代码如下:

oVideos=$Videos
Videos="Please select a video card: "
select myvideo in "Intel" \
"Intel i915" \
"Intel i965" \
"NVIDIA" \
"AMD" \
"ATI" \
"Radeon"
do
if [ "$REPLY" == "quit" ]; then
echo "OK, see you! Have a great one!"
exit
fi

if [ ! -z "$myvideo" ]; then
case $REPLY in
1) if [ checkVideoCard $REPLY == 0 ]; then
echo "VIDEO_CARDS=\"intel\"" >> $MAKECONF
fi

2) vCard=$(echo $REPLY | cut -d'i' -f 1)
if [ checkVideoCard $REPLY == 0 ]; then
echo "VIDEO_CARDS=\"intel i915\"" >> $MAKECONF
fi
esac
fi
done

...

checkVideoCard 是一个函数,旨在匹配用户的选择和 lspci 结果。别担心。

非常感谢!

最佳答案

您必须使用 ;; 终止与特定 case 值关联的命令:

case $REPLY in 
1) if [ "$(checkVideoCard "$REPLY")" = 0 ]; then
echo "VIDEO_CARDS=\"intel\"" >> $MAKECONF
fi
;;
# Because there's no difference among intel video cards, so please make sure what exact video card type you have.
2) vCard=$(echo $REPLY | cut -d'i' -f 1)
if [ "$(checkVideoCard "$REPLY")" = 0 ]; then
echo "VIDEO_CARDS=\"intel i915\"" >> $MAKECONF
fi
;;
esac

问题不在于赋值,而是在前一个未终止的情况下尝试使用 2) 开始一个新案例。

关于linux - vCard=$(echo $REPLY | cut -d'i' -f 1) 有什么问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33618208/

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