【发布时间】:2020-01-19 22:39:24
【问题描述】:
我一直在编写一个用于安装 Arch Linux 的脚本。我一直在 Windows 中运行的 VM 中测试脚本。当我在 VM 中测试部件并在 Windows 中编写它时。我一直在使用的应用程序是 Windows 中的 Notepadd++ 和 Linux VM 上的 vim。失败的部分是一开始的 for 循环,其他一切都按预期运行。如果我在linux中编写for循环,它就可以了。如果我在 Windows 中编写并复制它(通过 github),那部分会被跳过,就像它从未存在过一样,但我可以看到它是我在 vim 中查看的。在 windows 中编写一直是我编写脚本的主要方式,所以我真的不知道为什么只有这部分有问题。
无法正常工作的部分
ARGCASE="CHECK"
VMINSTALL="FALSE"
RSAUPASS="FALSE"
for arg in "$@"
do
case $ARGMODE in
CHECK)
case $arg in
-u | --username)
ARGMODE="USERNAME"
;;
-p | --userpass | --userpassword)
ARGMODE="USERPASS"
;;
-r | --rootpass | --rootpassword)
ARGMODE="ROOTPASS"
;;
-vm)
VMINSTALL="TRUE"
;;
-h | --help | *)
echo "This Script is for automating the install of arch linux"
echo "-u\t--username\n\tSet the user name of the users account"
echo "-p\t--userpass\t--userpassword\n\tSet the user password of the users account"
echo "-r\t--rootpass\t--rootpassword\n\tSet the root user's password"
echo "-vm\n\tThis is for when instaling to a virtual machine as some items are not needed since host machene takes care of them"
echo "-rsau\n\tSet Root user password to be the same as user\n\tNOTE: This is not recomended as this could be a security risk"
echo "-h\t--help\n\tshow this text"
exit 0
;;
esac
;;
USERNAME)
USERNAME=$arg
;;
USERPASS)
USERPASS=$arg
;;
ROOTPASS)
ROOTPASS=$arg
;;
esac
done
【问题讨论】:
-
你试过运行
diff来比较vim-version和notepad++-version吗?