|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
set -e +x
|
|
|
|
|
|
|
|
|
|
USAGE="Usage: $0 dep old new"
|
|
|
|
|
|
|
|
|
|
if [ $# -ne 3 ]; then
|
|
|
|
@ -7,16 +9,20 @@ if [ $# -ne 3 ]; then
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
CABALFILE=*.cabal
|
|
|
|
|
DEP=$1
|
|
|
|
|
OLD=$(echo $2 | sed -e "s/*/\\\\*/g" -e "s/\./\\\\./g")
|
|
|
|
|
NEW=$3
|
|
|
|
|
|
|
|
|
|
CABALFILE=$(ls *.cabal)
|
|
|
|
|
|
|
|
|
|
if [ $(ls $CABALFILE | wc -l) -ne 1 ]; then
|
|
|
|
|
if [ $(echo $CABALFILE | wc -w) -ne 1 ]; then
|
|
|
|
|
echo "There needs to be one .cabal file in the current dir!"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if ! grep -q "$1.*$2" $CABALFILE; then
|
|
|
|
|
echo "$CABALFILE does not match: $1 $2"
|
|
|
|
|
if ! grep -q "$DEP.*$OLD" $CABALFILE; then
|
|
|
|
|
echo "$CABALFILE does not match: $DEP $OLD"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
sed -i.$1 -e "s/\($1.*\)$2/\1$3/g" $CABALFILE
|
|
|
|
|
sed -i.$1 -e "s/\($DEP.*\)$OLD/\1$NEW/g" $CABALFILE
|
|
|
|
|