From f6169d702b9ea8acf847560e102319e52371f797 Mon Sep 17 00:00:00 2001 From: Aaron Schrab Date: Thu, 27 Dec 2012 20:33:25 -0800 Subject: [PATCH] Use the directory where the version.sh script is located as the directory where it is run. Since this will be run in a separate shell anyway, there's no need to worry about changing current directory. This eliminates the need for the caller to specify where the source directory is located, and doesn't require that the code take special care to use the appropriate directory. The fallback method of using `cat VERSION` was broken in this respect, it would not work when run from a different directory. --- configure.ac | 2 +- version.sh | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) --- configure.ac | 2 +- version.sh | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index d605da25d..ee60d79d1 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ AC_CONFIG_HEADERS([config.h]) AC_SUBST([CONFIG_STATUS_DEPENDENCIES], ['$(top_srcdir)/VERSION']) -MUTT_VERSION=`env HGROOT="$srcdir" sh "$srcdir/version.sh"` +MUTT_VERSION=`env sh "$srcdir/version.sh"` AC_DEFINE_UNQUOTED(MUTT_VERSION,"$MUTT_VERSION", [Full textual version string.]) AC_USE_SYSTEM_EXTENSIONS diff --git a/version.sh b/version.sh index a3ace4e02..57d641460 100644 --- a/version.sh +++ b/version.sh @@ -1,13 +1,15 @@ #!/bin/sh -# Adopt $HGROOT from the environment, if present HG=hg -[ -n "$HGROOT" ] && HG="$HG -R \$HGROOT" + +# Switch to directory where this script lives so that further commands are run +# from the root directory of the source +cd `dirname $0` # Ensure that we have a repo here and that mercurial is installed. If # not, just cat the VERSION file; it contains the latest release number. -{ [ -d "$HGROOT/.hg" ] && $HG >/dev/null 2>&1; } \ -|| exec cat "$HGROOT/VERSION" +{ [ -d ".hg" ] && $HG >/dev/null 2>&1; } \ +|| exec cat VERSION # This is a mercurial repo and we have the hg command. -- 2.40.0