Shell Scripting错误

Jab*_*bez 2 unix shell scripting

我是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   
Run Code Online (Sandbox Code Playgroud)

我发布了用于运行它的命令以及使用这些命令时出现的错误.

----------
./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
Run Code Online (Sandbox Code Playgroud)

我试着以太多的方式解决它,并在发布之前搜索了很多东西.但我所有的考验都是徒劳的.请告诉我在哪里我犯了错误,因为我刚接触shell脚本.

提前致谢.

Mar*_*tos 6

[是一个命令,但您正在尝试调用该命令[1=1].添加一些空格:

if [ "$DBG" = "1" ]; then
Run Code Online (Sandbox Code Playgroud)