#!/bin/bash --norc # Usage: ./.do_setversion {currentversionstr} {newversionstr} cat << ! These files will be revised... ! ( echo -e "readme.txt: \c"; egrep '^Stable tag: ' readme.txt | head -1 echo -e "readme.txt: \c"; egrep '^Version: ' readme.txt | head -1 echo -e "backgammon.php: \c"; egrep '^Version: ' backgammon.php | head -1 echo -e "backgammon.php: \c"; egrep 'define..FHK_BACKGAMMON_VERSION.,' backgammon.php | head -1 ) | cat -n | sed -e 's/^/ /' if [ "${1}x" == 'x' -o "${2}x" == 'x' ]; then echo "" >&2 echo "Usage: ./.do_setversion {currentversionstr} {newversionstr}" >&2 exit 1 fi if [ "${1}x" == "${2}x" ]; then echo "" >&2 echo "Refusing to update from same version. Nothing to do." >&2 exit 3 fi V=$(egrep 'define..FHK_BACKGAMMON_VERSION.,' backgammon.php | head -1 | sed -e 's/^.*, *//' -e "s/'//g" -e 's/);//') if [ "${V}x" == "${2}x" ]; then echo "" >&2 echo "The version already appears to be set to version $2. Nothing to do." >&2 exit 4 fi if [ "${V}x" != "${1}x" ]; then echo "" >&2 echo "Detected current version as $V ... doesn't match $1 ... try using: ./.do_setversion $V $2" >&2 exit 2 fi echo "" >&2 echo "Current version is $V ... will reset to $2" >&2 sedfiles "^Stable tag: $V" "Stable tag: $2" readme.txt sedfiles "^Version: $V" "Version: $2" readme.txt sedfiles "^Version: $V" "Version: $2" backgammon.php sedfiles "'FHK_BACKGAMMON_VERSION', '$V'" "'FHK_BACKGAMMON_VERSION', '$2'" backgammon.php exit 0