我对shell脚本非常陌生,并且一直在为下面的shell脚本而苦苦挣扎。我将我在下面使用的脚本和命令张贴出来,供您参考,请帮助我纠正我所犯的错误。
#
#
#
DBG=0
RLS=0
ALL=0
CLN=0
print_help_uu()
{
echo "Usage: $0 -D -R -A -C ";
echo "Where -C clean the debug project builds";
echo " -D to build in DEBUG config";
echo " -R to build in RELEASE config";
echo " -A to build in both configs";
return
}
#
# Main procedure start here
#
# Check for sufficent args
#
if [ $# -eq 0 ] ; then
print_help_uu
exit 1
fi
#
# Function to clean the project
#
clean()
{
if ["$DBG"="1"]; then
echo "Cleaning debug"
if ["$RLS"="1"]; then
echo "cleaning release + debug"
else
echo "This is bad"
fi
fi
if ["$RLS"="1"]; then
echo "Cleaning release "
fi
return
}
while getopts "DRAC" opt
do
case "$opt" in
D) DBG=1;;
R) RLS=1;;
A) DBG=1;RLS=1;;
C) CLN=1;;
\?) print_help_uu; exit 1;;
esac
clean
done 我发布了我用来运行它的命令,以及使用这些命令时得到的错误。
----------
./BuildProject.sh -D
./BuildProject.sh: line 36: [1=1]: command not found
./BuildProject.sh: line 46: [0=1]: command not found
-----------
sh BuildProject.sh -D
BuildProject.sh: 63: [1=1]: not found
BuildProject.sh: 63: [0=1]: not found
-----------
sh ./BuildProject.sh -D
./BuildProject.sh: 63: [1=1]: not found
./BuildProject.sh: 63: [0=1]: not found我试着用很多方法来解决这个问题,在这里发帖之前我用谷歌搜索了很多。但我所有的试验都是徒劳的。请告诉我我在哪里犯了错,因为我是shell脚本的新手。
提前谢谢。
发布于 2009-12-28 18:35:51
这确实是一个空间问题。
VAR=VALUE仅用于shell中的变量声明,而
VAR = VALUE仅用于变量测试。这很棘手,你只需要习惯它。
https://stackoverflow.com/questions/1968827
复制相似问题