a patch for ac-helpers/gnu-{diff,patch}.sh
From: Akinori MUSHA <knu_at_iDaemons.org>
Date: 2001-11-03 16:22:39 CET
Hi,
Attached is a patch to make ac-helpers/gnu-{diff,patch}.sh scripts
On such platforms as FreeBSD, GNU diff and GNU patch are installed as
Please merge this if it's okay.
-- / /__ __ Akinori.org / MUSHA.org / ) ) ) ) / FreeBSD.org / Ruby-lang.org Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp "Freeze this moment a little bit longer, make each impression a little bit stronger.. Experience slips away -- Time stand still" Index: ac-helpers/gnu-diff.sh =================================================================== RCS file: /usr/local/tigris/data/helm/cvs/repository/subversion/ac-helpers/gnu-diff.sh,v retrieving revision 1.2 diff -u -r1.2 gnu-diff.sh --- ac-helpers/gnu-diff.sh 2001/08/28 14:44:48 1.2 +++ ac-helpers/gnu-diff.sh 2001/11/03 14:16:36 @@ -5,8 +5,9 @@ # particular, this means looking for GNU diff. # # Note: FreeBSD's `diff' claims to be GNU, but is actually a hacked -# version that fails this test. Native versions of `diff' on other -# Unices probably fail this test as well. +# version that fails this test. Native versions of `diff' on +# other Unices probably fail this test as well. Install GNU +# patch and GNU diffutils from the ports/packages. # # # Usage: gnu-diff.sh PATCHPATH @@ -23,51 +24,46 @@ exit 1 fi -gnu_diff_path="" -gnu_patch_path=$1 -pathlist=$PATH -final="no" +patch=$1 # Loop over $PATH, looking for `diff' binaries -while test "$final" != ""; do - searchdir=`echo $pathlist | sed -e 's/:.*$//'` - final=`echo $pathlist | grep :` - pathlist=`echo $pathlist | sed -e 's/^[^:]*://'` - - # does $searchdir contain an executable called `diff'? - if test -f ${searchdir}/diff -o -h ${searchdir}/diff; then - if test -x ${searchdir}/diff; then - - # create two identical one-line files (no newline endings) - echo -n "some text, no newline" > foofile - cp foofile foofile2 - - # append to the first file - echo -n "...extra text, still no newline" >> foofile - - # do a diff, create a patch. - ${searchdir}/diff -u foofile foofile2 > foo.patch 2>/dev/null - - # apply the patch to foofile2 - ${gnu_patch_path} < foo.patch 2>&1 >/dev/null - - # the files should be *identical* now. - cmp -s foofile foofile2 2>&1 >/dev/null - if test $? -eq 0; then - gnu_diff_path=${searchdir}/diff - final="" - fi +IFS=':' - # cleanup - rm foofile foofile2 foo.patch *.rej *.orig 2>/dev/null - - fi - fi +for searchdir in $PATH; do + # does $searchdir contain an executable called either `gdiff' or `diff'? + for name in gdiff diff; do + diff=$searchdir/$name + if test -x $diff; then + # create two identical one-line files (no newline endings) + echo -n "some text, no newline" > foofile + cp foofile foofile2 + + # append to the first file + echo -n "...extra text, still no newline" >> foofile + + # do a diff, create a patch. + $diff -u foofile foofile2 > foofile.patch 2>/dev/null + + # apply the patch to foofile2 + $patch < foofile.patch >/dev/null 2>&1 + + # the files should be *identical* now. + if cmp -s foofile foofile2; then + identical=yes + else + identical=no + fi + + # cleanup + rm -f foofile* + + if test "$identical" = "yes"; then + echo $diff + exit + fi + fi + done done - -echo $gnu_diff_path - - - +echo "" Index: ac-helpers/gnu-patch.sh =================================================================== RCS file: /usr/local/tigris/data/helm/cvs/repository/subversion/ac-helpers/gnu-patch.sh,v retrieving revision 1.1 diff -u -r1.1 gnu-patch.sh --- ac-helpers/gnu-patch.sh 2001/06/27 19:46:21 1.1 +++ ac-helpers/gnu-patch.sh 2001/11/03 14:16:36 @@ -4,34 +4,20 @@ # Print the full path to this program, else print "". # -gnu_patch_path="" -pathlist=$PATH -final="no" +IFS=':' -# Could this loop *be* any uglier? -# I can't believe it's the 21st century, and I'm using bourne. - -while test "$final" != ""; do - searchdir=`echo $pathlist | sed -e 's/:.*$//'` # barf. - final=`echo $pathlist | grep :` - pathlist=`echo $pathlist | sed -e 's/^[^:]*://'` # where's my (cdr)? - - # does $searchdir contain an executable called `patch'? - if test -f ${searchdir}/patch -o -h ${searchdir}/patch; then - if test -x ${searchdir}/patch; then - # run `patch --version` - output=`${searchdir}/patch --version 2>/dev/null` - if test $? != 0; then - # `patch --version` returned error; keep looking. - continue - fi - # else, look for "GNU" in the output. - if test "`echo $output | grep GNU`" != ""; then - gnu_patch_path="${searchdir}/patch" - break - fi - fi - fi +for searchdir in $PATH; do + # does $searchdir contain an executable called either `gpatch' or `patch'? + for name in gpatch patch; do + patch=$searchdir/$name + if test -x $patch; then + # run `patch --version` + if $patch --version 2>&1 | grep -qw GNU; then + echo $patch + exit + fi + fi + done done -echo $gnu_patch_path +echo "" --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org For additional commands, e-mail: dev-help@subversion.tigris.orgReceived on Sat Oct 21 14:36:47 2006 |
This is an archived mail posted to the Subversion Dev mailing list.
This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.