At 18:10 -0600 14 Dec 2012, David Champion <d...@bikeshed.us> wrote:
This is good to add support for, but note that the ${a#b} and ${a%b}
family of parameter expressions is nonportable.  These are commonly
accepted bashisms that also work in zsh, but not in xpg4 shells.

Can you redo with seds, or something?

I hadn't realized that those weren't portable. I did the testing with dash to try to avoid, bash-specific features but of course that supports some non-standard features itself.

Updated version of that patch using sed instead follows.

---- 8< ------

Subject: [PATCH] version.sh: Get detailed version info from git

If not able to use mercurial to build a detailed version string, try
using git to do so.
---
version.sh |   23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)

diff --git a/version.sh b/version.sh
index 39709a0..35e5604 100644
--- a/version.sh
+++ b/version.sh
@@ -64,6 +64,29 @@ if [ -d .hg ] && $HG >/dev/null 2>&1; then
        exit 0
fi

+# If in a git repo, and git is present use that to build detailed version 
string
+if git rev-parse 2> /dev/null; then
+       version=`git describe --long --dirty --tags --match 'mutt-*-rel'`
+
+       case "$version" in
+         *-dirty)
+               dirty=+
+               version=`echo $version | sed -e s/-dirty//`
+               ;;
+       esac
+
+       commit=`  echo $version|sed -e's/.*-//'`
+       version=` echo $version|sed -e's/-[^-]*$//'`
+
+       distance=`echo $version|sed -e's/.*-//'`
+       version=` echo $version|sed -e's/-[^-]*$//'`
+
+       version=` echo $version|sed -e's/^mutt-//' -e's/-rel$//' -e'y/-/./'`
+
+       echo "$version+$distance ($commit$dirty)"
+       exit 0
+fi
+
# If nothing else worked, just cat the VERSION file;
# it contains the latest release number.
cat VERSION
--
1.7.10.4

Reply via email to