【发布时间】:2013-09-23 23:15:59
【问题描述】:
我想使用 bash 获取当前的 svn 版本并将其设置为环境变量 SVN_REVISION。此环境变量可能已设置,也可能尚未设置。如果它已经设置然后我回显它,如果没有设置那么我计算它然后回显它。如果 SVN_REVISION 已设置,我不想覆盖。我正在使用以下脚本,由于我对参数扩展缺乏了解,该脚本失败了。
#!/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
我该如何解决?
【问题讨论】:
标签: bash shell svn parameters expansion