From 1cb0fba5fbdfb893b4755df20d4bc0ada539b70c Mon Sep 17 00:00:00 2001 From: Jens Petersen Date: Fri, 22 Jun 2012 14:47:51 +0900 Subject: [PATCH] cabal-tweak-dep-ver: quote wildcards in match string and show file name when no match --- cabal-tweak-dep-ver | 16 +++++++++++----- ghc-rpm-macros.spec | 6 +++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/cabal-tweak-dep-ver b/cabal-tweak-dep-ver index b637eed..2033160 100755 --- a/cabal-tweak-dep-ver +++ b/cabal-tweak-dep-ver @@ -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 diff --git a/ghc-rpm-macros.spec b/ghc-rpm-macros.spec index c5ac739..138596a 100644 --- a/ghc-rpm-macros.spec +++ b/ghc-rpm-macros.spec @@ -3,7 +3,7 @@ %global macros_file %{_sysconfdir}/rpm/macros.ghc Name: ghc-rpm-macros -Version: 0.95.4 +Version: 0.95.4.1 Release: 1%{?dist} Summary: Macros for building packages for GHC @@ -64,6 +64,10 @@ EOF %changelog +* Fri Jun 22 2012 Jens Petersen - 0.95.4.1-1 +- cabal-tweak-dep-ver: show file name when no match +- cabal-tweak-dep-ver: backslash quote . and * in the match string + * Fri Jun 22 2012 Jens Petersen - 0.95.4-1 - new cabal-tweak-dep-ver script to tweak depends version bounds in .cabal