[PATCH 2 of 6 STABLE] builddeb: use sed -i

Sean Farley sean at farley.io
Mon Apr 18 13:52:09 EDT 2016


# HG changeset patch
# User Sean Farley <sean at farley.io>
# Date 1460835201 25200
#      Sat Apr 16 12:33:21 2016 -0700
# Branch stable
# Node ID da3179bb3ca884e261034064c546d184dcd32a3a
# Parent  db33d0e7476c79ac0bc8048992ec6d24d6062c87
# EXP-Topic ppa
builddeb: use sed -i

Notice that there is no space after '-i'. This makes it work on both GNU and
BSD versions of sed.

diff --git a/contrib/builddeb b/contrib/builddeb
--- a/contrib/builddeb
+++ b/contrib/builddeb
@@ -65,15 +65,12 @@ if [ "$BUILD" ]; then
     fi
 
     cp -r $PWD/contrib/debian debian
     chmod -R 0755 debian
 
-    # This looks like sed -i, but sed -i behaves just differently enough
-    # between BSD and GNU sed that I gave up and did the dumb thing.
-    sed "s/__VERSION__/$debver/" < $changelog > $changelog.tmp
-    date=$(date --rfc-2822)
-    sed "s/__DATE__/$date/" < $changelog.tmp > $changelog
+    sed -i.tmp "s/__VERSION__/$debver/" $changelog
+    sed -i.tmp "s/__DATE__/$(date --rfc-2822)/" $changelog
     rm $changelog.tmp
 
     debuild -us -uc -b
     if [ $? != 0 ]; then
         echo 'debuild failed!'


More information about the Mercurial-devel mailing list