我正在尝试编写一个 bash 脚本来自动将文件从我的构建和源目录(具有共享对象二进制文件)分别复制到我的系统/usr/lib
和/usr/include
目录。
当我运行以下命令时:
#!/bin/bash
RELEASE_ARG = "--release"
DEBUG_ARG = "--debug"
DEST_NAME = "libEngine.so"
SRC_NAME = "libEngineSO.so"
ENGINE_DBG_DEST = "/usr/lib/Stitches/Debug/$DEST_NAME"
ENGINE_REL_DEST = "/usr/lib/Stitches/Release/$DEST_NAME"
ENGINE_REL_SRC = "$STITCH_ROOT/Engine__Release/$SRC_NAME"
ENGINE_DBG_SRC = "$STITCH_ROOT/Engine__Debug/$SRC_NAME"
if [ ! -z $1 ]; then
#foo
echo "No argument specified; please specify either ${RELEASE_ARG} or $DEBUG_ARG. K BAI\n"
exit
elif [ -z $1 -eq RELEASE_ARG ]; then
#wat
echo "If you actually chose this option, you better be damn ready to distribute...\n"
echo "Updating Release directory in $ENGINE_REL_DEST\n"
cp $ENGINE_REL_SRC $ENGINE_REL_DEST
elif [ -z $1 -eq DEBUG_ARG ]; then
#reasonable and realistic
echo "Good choice...\n"
echo "Updating Debug directory in $ENGINE_DBG_DEST\n"
cp $ENGINE_DBG_SRC $ENGINE_DBG_DEST
fi
echo "Sex ;)"
我得到这个输出:
x@x ~/Programming/Stitches-Qt/scripts $ sh postbuild.sh --debug
postbuild.sh: 3: postbuild.sh: DEBUG: not found
postbuild.sh: 5: postbuild.sh: RELEASE_ARG: not found
postbuild.sh: 6: postbuild.sh: DEBUG_ARG: not found
postbuild.sh: 8: postbuild.sh: DEST_NAME: not found
postbuild.sh: 10: postbuild.sh: SRC_NAME: not found
postbuild.sh: 12: postbuild.sh: ENGINE_DBG_DEST: not found
postbuild.sh: 13: postbuild.sh: ENGINE_REL_DEST: not found
postbuild.sh: 15: postbuild.sh: ENGINE_REL_SRC: not found
postbuild.sh: 16: postbuild.sh: ENGINE_DBG_SRC: not found
No argument specified; please specify either or . K BAI
如您所见,我必须不正确地使用变量或其他东西。我如何完成我在这里尝试做的事情?
PS,我知道除非我是 root 否则我不能这样做,所以我在/usr/lib
|中创建了一个子目录 /usr/include
所以我可以把它改成我的用户名。所以,这应该工作......