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?

* On 13 Dec 2012, Aaron Schrab wrote: 
> From: Aaron Schrab <aa...@schrab.com>
> 
> If not able to use mercurial to build a detailed version string, try
> using git to do so.
> ---
>  version.sh |   26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/version.sh b/version.sh
> index 39709a0..54568ac 100644
> --- a/version.sh
> +++ b/version.sh
> @@ -64,6 +64,32 @@ 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=${version%-dirty}
> +             ;;
> +     esac
> +
> +     commit=${version##*-}
> +     version=${version%-*}
> +
> +     distance=${version##*-}
> +     version=${version%-*}
> +
> +     version=${version#mutt-}
> +     version=${version%-rel}
> +
> +     version=`echo $version | tr - .`
> +
> +     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

-- 
David Champion • d...@bikeshed.us

Reply via email to