[2016-09-07 10:17] Philipp Takacs <phil...@bureaucracy.de> > > Thanks for your feedback a updated patch is attached, this contains most > of your suggestion.
I've tested it now. Some further comments below ... > > > +VERSION = `head -n 1 $(srcdir)/VERSION` > > > > Better portable and even less to type: > > > > VERSION = `sed q $(srcdir)/VERSION` Btw: For the background: The reason why there was tail(1) since 7th Edition but not head(1), is that head(1) could easily be replaced by sed 10q (or sed 11q for faster typing). Hence there just was no need to have head(1) ... until people found sed(1) strange (apart from s///) and wanted something easier. See also: http://harmful.cat-v.org/software/ Now about your new patch: > diff --git a/version.sh b/version.sh > new file mode 100755 > index 0000000..3d7764b > --- /dev/null > +++ b/version.sh > @@ -0,0 +1,23 @@ > +#!/bin/sh > +# > +# version.sh -- script to create version string(s) for mmh. > +# > +# You need to pass the script the top source directory. > +# > + > +if [ -z "$1" ] || [ ! -d "$1" ]; then > + echo "usage: version.sh topdir" 1>&2 > + exit 1 The indent here are spaces instead of tabs. > +fi > + > +cd $1 Instead of the above code, I suggest you use: if [ -d "$1" ]; then cd "$1" # <-- quotes! fi Then we can invoke version.sh with or without argument. (For testing I usually call `./version.sh' ... it would be tedious to always supply a dot.) Then you should update ./Makefiles.in and remove the dot there. > + > +VERSION="`sed q VERSION`" Use lowercase for the shell variable. > + > +git_info="" > + > +if [ -d "$1/.git" ]; then There is a bug! Use: if [ -d .git ]; then instead, as we already are in the right directory. > + git_info="+`git log -n 1 --pretty'=format:%h' HEAD`" This always adds git hashes if we have .git, even if we are at a release version. My suggestion is: current=`git log -n 1 --pretty=format:%h HEAD` release=`git log -n 1 --pretty=format:%h "mmh-$version"` if [ "$current" != "$release" ]; then git_info="+$current" fi > +fi > + > +echo mmh-"$VERSION""$git_info" One further thing we have to update as well is configure.ac. It appears to be enough to replace: AC_INIT(mmh, m4_normalize(m4_include([VERSION]))) with: AC_INIT(mmh, m4_normalize(`./version.sh`)) (Don't know if this is autoconf style but it works.) meillo P.S. About the `+' in the version number suffix: I used the `+' instead of a `-' because I wanted to express that e.g. mmh-0.3+dev is mmh-0.3 plus further development and not be confused with mmh-0.3-rc1 (which is ``not yet 0.3''). Now as we have commit hashes, I don't see this ambiguity anymore, we could use `-' again to append the git hash if you would prefer that. I don't care.