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