我想使用bash获取当前的svn修订版并将其设置为环境变量SVN_REVISION。此环境变量可能已经设置,也可能没有设置。如果它已经设置,然后我回应,如果没有设置,然后我计算它,然后回声。如果SVN_REVISION已设置,我不想重写。我正在使用以下由于缺乏对参数扩展的理解而失败的脚本。在bash中分配环境变量的参数扩展
#!/bin/bash
# If no directory provided as an argument, uses the current working directory as the source directory.
RAW_SRC_DIR=${1:-`pwd`}
COMPUTE_REVISION=$(svn info ${RAW_SRC_DIR} | grep '^Revision' | cut -d ':' -f2 | tr -d ' ')
echo "${COMPUTE_REVISION}" ##Gets the revision successfully
${SVN_REVISION:="$COMPUTE_REVISION"} #Fails with message: <SVN_REVISION> command not found
export SVN_REVISION
echo $SVN_REVISION
如何解决?
合作。谢谢! –