から呼び出す次のスクリプトがあります.bash_profile
。
# Set directories based on current path
__set_dirs() {
currdir=`pwd`
if [[ ${currdir} =~ "\/path\/to\/main\/(.*)\/working\/([a-z]+)(/?.*)" ]]
then
ws=${BASH_REMATCH[1]}
subdirs=${BASH_REMATCH[3]}
stgdir=${ts}/${ws}/STAGING${subdirs}
else
echo "${currdir} is not a workspace"
stgdir=""
fi
}
# Update local version with staging version
upd() {
__set_dirs
if [[ -n ${stgdir} ]]
then
__overwrite=0
while getopts "o" opt
do
case $opt in
o)
__overwrite=1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
esac
done
echo "Updating ${currdir} with latest from ${stgdir}..."
if [ ${__overwrite} -eq 0 ]
then
update -r ${stgdir} ${currdir}
else
echo "Overwriting all local changes!"
update -r -w ${stgdir} ${currdir}
fi
fi
unset __overwrite
}
私が実行するとき
> upd -o
フラグは完全に無視されます。「すべてのローカル変更を上書きしています!」というメッセージは表示されません。私はどこかで何かを逃しましたか?
更新:機能しますが、スクリプトを初めて実行するときだけです。2 回目以降、フラグは無視されます。