Discussion:
[PATCH] git-version-gen: allow empty string as --prefix
(too old to reply)
Sami Kerola
2017-02-11 16:15:29 UTC
Permalink
Raw Message
There are projects that try use this script, but do not have convention to
use 'v' in front of tags. Earlier one had to change script default not to
include 'v'. After this change the --prefix option can be used as last
argument without options in AC_INIT() to achieve the same.
---
build-aux/git-version-gen | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
index 079849d5e..f493d8157 100755
--- a/build-aux/git-version-gen
+++ b/build-aux/git-version-gen
@@ -101,7 +101,7 @@ while test $# -gt 0; do
case $1 in
--help) echo "$usage"; exit 0;;
--version) echo "$version"; exit 0;;
- --prefix) shift; prefix=${1?};;
+ --prefix) shift; prefix="${1:-''}";;
--fallback) shift; fallback=${1?};;
-*)
echo "$0: Unknown option '$1'." >&2
--
2.11.1
Bruno Haible
2017-02-11 18:01:12 UTC
Permalink
Raw Message
Hi,
Post by Sami Kerola
There are projects that try use this script, but do not have convention to
use 'v' in front of tags. Earlier one had to change script default not to
include 'v'. After this change the --prefix option can be used as last
argument without options
In most cases, long options can be passed to programs in any order. If it's not
possible, it's surprising.

Why would this be better than to pass an empty argument explicitly?
I mean, in shell syntax:
--prefix ''

The other idea is to allow a --prefix=VALUE syntax; this can accommodate an
empty value without effort:
--prefix=

Bruno
Sami Kerola
2017-02-12 08:47:11 UTC
Permalink
Raw Message
Post by Bruno Haible
Post by Sami Kerola
There are projects that try use this script, but do not have convention to
use 'v' in front of tags. Earlier one had to change script default not to
include 'v'. After this change the --prefix option can be used as last
argument without options
In most cases, long options can be passed to programs in any order. If it's not
possible, it's surprising.
Why would this be better than to pass an empty argument explicitly?
--prefix ''
The other idea is to allow a --prefix=VALUE syntax; this can accommodate an
--prefix=
Hi Bruno and others,

Using --prefix '' works fine when runnign from command line, but I could not
make empty string and AC_INIT to play together without the macro starting
to throw warnings. Here is how that turns out:

$ head -1 configure.ac
AC_INIT([logrotate],[m4_esyscmd([build-aux/git-version-gen --prefix ''
.tarball-version])],

$ ./autogen.sh
configure.ac:1: warning: AC_INIT: not a literal:
m4_esyscmd([build-aux/git-version-gen --prefix '' .tarball-version])
configure.ac:1: warning: AC_INIT: not a literal:
m4_esyscmd([build-aux/git-version-gen --prefix '' .tarball-version])
configure.ac:1: warning: AC_INIT: not a literal:
m4_esyscmd([build-aux/git-version-gen --prefix '' .tarball-version])
configure.ac:1: warning: AC_INIT: not a literal:
m4_esyscmd([build-aux/git-version-gen --prefix '' .tarball-version])
configure.ac:1: warning: AC_INIT: not a literal:
m4_esyscmd([build-aux/git-version-gen --prefix '' .tarball-version])
The logrotate build system is now prepared. To build here, run:
./configure && make
--
Sami Kerola
http://www.iki.fi/kerolasa/
Eric Blake
2017-02-13 17:26:36 UTC
Permalink
Raw Message
Post by Sami Kerola
Using --prefix '' works fine when runnign from command line, but I could not
make empty string and AC_INIT to play together without the macro starting
$ head -1 configure.ac
AC_INIT([logrotate],[m4_esyscmd([build-aux/git-version-gen --prefix ''
.tarball-version])],
Too much quoting. This is one case where you WANT to expand the
m4_esyscmd early, as in:

AC_INIT([logrotate],
m4_esyscmd([build-aux/git-version-gen --prefix ''
.tarball-version]))
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Loading...