【发布时间】:2018-01-20 00:09:11
【问题描述】:
我试图将用户输入与字符串进行比较 这是我的代码
Encode="Encode"
Decode="Decode"
printf "Enter name of file: "
read fileName
printf "Encode Or Decode: "
read EncOrDec
if [ "$Encode"=="$EncOrDec" ]; then
printf "Encode Nice\n"
elif [ "$Decode"=="$EncOrDec" ]; then
printf "Decode Nice\n"
else
printf "Nothing\n"
fi
它总是转到 Encode 语句,为什么? 以及如何解决它
【问题讨论】:
-
这个问题会被shellcheck.net自动检测到;考虑在此处提问之前养成运行代码的习惯。
-
顺便说一句,在尝试编写问题标题时,请尽量描述具体问题——即。不仅仅是“X的问题”,而是“为什么X在预期Z的时候做Y?”。我试图在这里为此进行编辑;这样人们就可以一眼看出他们是否有同样的问题(如果问题得到了回答),或者他们是否有可能提供帮助(如果没有)。