You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ghc-rpm-macros/cabal-tweak-drop-dep

33 lines
538 B

#!/bin/sh
set -e +x
function fail {
echo "$0: $1" >&2
exit 1
}
USAGE="Usage: $0 dep"
if [ $# -ne 1 ]; then
fail "$USAGE"
fi
DEP=$1
CABALFILE=$(ls *.cabal)
if [ $(echo $CABALFILE | wc -w) -ne 1 ]; then
fail "There needs to be one .cabal file in the current dir!"
fi
if [ ! -f $CABALFILE.orig ]; then
BACKUP=.orig
fi
if grep "$DEP" $CABALFILE | sed -e "s/$DEP//" | grep -q -e "[A-Za-z]"; then
fail "$0: deleting whole $DEP lines not safe - try more precise pattern"
fi
sed -i$BACKUP -e "/$DEP/d" $CABALFILE