使用bash IProject.sh
想要添加bash -h IProject.sh
使用-h
(人类),我希望它能够打印出更多信息。
我的代码是......
while getopts h name
do
case $name in
h) humanOpt=1;;
esac
done
#TESTING HERE
echo "$humanOpt"
if [[ ! -z $humanOpt]]; then
human version
else
computer version
fi
但是,我只在其他地方打印语句。为什么会这样?
答案 0 :(得分:2)
我想你可以通过一些试验和错误来判断自己
bash IProject.sh -h
完成这项工作。但是你需要为bash呼吸填补更多的空间
if [[ ! -z $humanOpt ]]; then # here
。您的第一个猜测bash -h IProject.sh
将-h添加为bash命令本身的选项,而不是IProject.sh
调用。