|
|
@ -5,11 +5,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
set -e +x
|
|
|
|
set -e +x
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function fail {
|
|
|
|
|
|
|
|
echo "$0: $1" >&2
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
USAGE="Usage: $0 FLAG [True|False]"
|
|
|
|
USAGE="Usage: $0 FLAG [True|False]"
|
|
|
|
|
|
|
|
|
|
|
|
if [ $# -ne 2 ]; then
|
|
|
|
if [ $# -ne 2 ]; then
|
|
|
|
echo "$USAGE"
|
|
|
|
fail "$USAGE"
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
FLAG=$1
|
|
|
|
FLAG=$1
|
|
|
@ -24,23 +28,19 @@ esac
|
|
|
|
CABALFILE=$(ls *.cabal)
|
|
|
|
CABALFILE=$(ls *.cabal)
|
|
|
|
|
|
|
|
|
|
|
|
if [ $(echo $CABALFILE | wc -w) -ne 1 ]; then
|
|
|
|
if [ $(echo $CABALFILE | wc -w) -ne 1 ]; then
|
|
|
|
echo "There needs to be one .cabal file in the current dir!"
|
|
|
|
fail "There needs to be one .cabal file in the current dir!"
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if ! grep -q -i "^flag *$FLAG" $CABALFILE; then
|
|
|
|
if ! grep -q -i "^flag *$FLAG" $CABALFILE; then
|
|
|
|
echo "$CABALFILE does not have flag $FLAG"
|
|
|
|
fail "$CABALFILE does not have flag $FLAG"
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if ! grep -A3 -i "^flag *$FLAG" $CABALFILE | grep -q -i "default:"; then
|
|
|
|
if ! grep -A3 -i "^flag *$FLAG" $CABALFILE | grep -q -i "default:"; then
|
|
|
|
echo "$CABALFILE: $FLAG flag might not have a default"
|
|
|
|
fail "$CABALFILE: $FLAG flag might not have a default"
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if ! grep -A3 -i "^flag *$FLAG" $CABALFILE | grep -q -i "default: *$OLD"; then
|
|
|
|
if ! grep -A3 -i "^flag *$FLAG" $CABALFILE | grep -q -i "default: *$OLD"; then
|
|
|
|
echo "$CABALFILE: $FLAG flag already defaults to $NEW"
|
|
|
|
fail "$CABALFILE: $FLAG flag already defaults to $NEW"
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ ! -f $CABALFILE.orig ]; then
|
|
|
|
if [ ! -f $CABALFILE.orig ]; then
|
|
|
|