[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Fix STEPMAKE_GET_VERSION for OpenBSD
From: |
Matthias Kilian |
Subject: |
Re: Fix STEPMAKE_GET_VERSION for OpenBSD |
Date: |
Tue, 15 Dec 2009 20:01:49 +0100 |
User-agent: |
Mutt/1.4.2.3i |
On Tue, Dec 15, 2009 at 04:33:14PM +0100, Jan Nieuwenhuizen wrote:
> > (I really
> > don't remember the reason, too much time has passed since I made
> > this patch)
>
> It would be nice to know why we need this, esp. as this fix
> does not make the logic more readible.
Not necessary, I aready had a closer look. It's failing in grep(1)
for \|, which is undefined by POSIX (for basic regular expressions) and
obviously support by GNU grep but not by OpenBSDs grep.
So a much simpler fix is to use
grep -E '(^| )[0-9][0-9]*\.[0-9]'
instead of
grep -E '\(^\| \)[0-9][0-9]*\.[0-9]'
Here's a diff that does exactly this:
diff --git a/stepmake/aclocal.m4 b/stepmake/aclocal.m4
index 83c07c3..5bd8b73 100644
--- a/stepmake/aclocal.m4
+++ b/stepmake/aclocal.m4
@@ -32,9 +32,9 @@ AC_DEFUN(STEPMAKE_GET_VERSION, [
## for compatibility reasons.
## grab the first version number in --version output.
- eval _ver=\"\`("$1" --version || "$1" -V) 2>&1 | grep '\(^\|
\)[0-9][0-9]*\.[0-9]' \
+ eval _ver=\"\`("$1" --version || "$1" -V) 2>&1 | grep -E '(^|
)[0-9][0-9]*\.[0-9]' \
| head -n 1 \
- | tr ' ' '\n' | sed 's/\([0-9][0-9]*\.[0-9][0-9.]*\).*/\1/g' | grep
'\(^\| \)[0-9][0-9]*\.[0-9]' | head -n 1\`\"
+ | tr ' ' '\n' | sed 's/\([0-9][0-9]*\.[0-9][0-9.]*\).*/\1/g' | grep -E
'(^| )[0-9][0-9]*\.[0-9]' | head -n 1\`\"
if test -z "$_ver"; then
## If empty, try date [fontforge]
An alternative diff, which just adds some linebreaks and avoids line
continuations using backslash-newline: (for improving readability a
little bit):
diff --git a/stepmake/aclocal.m4 b/stepmake/aclocal.m4
index 83c07c3..09afbff 100644
--- a/stepmake/aclocal.m4
+++ b/stepmake/aclocal.m4
@@ -32,9 +32,13 @@ AC_DEFUN(STEPMAKE_GET_VERSION, [
## for compatibility reasons.
## grab the first version number in --version output.
- eval _ver=\"\`("$1" --version || "$1" -V) 2>&1 | grep '\(^\|
\)[0-9][0-9]*\.[0-9]' \
- | head -n 1 \
- | tr ' ' '\n' | sed 's/\([0-9][0-9]*\.[0-9][0-9.]*\).*/\1/g' | grep
'\(^\| \)[0-9][0-9]*\.[0-9]' | head -n 1\`\"
+ eval _ver=\"\`("$1" --version || "$1" -V) 2>&1 |
+ grep -E '(^| )[0-9][0-9]*\.[0-9]' |
+ head -n 1 |
+ tr ' ' '\n' |
+ sed 's/\([0-9][0-9]*\.[0-9][0-9.]*\).*/\1/g' |
+ grep -E '(^| )[0-9][0-9]*\.[0-9]' |
+ head -n 1\`\"
if test -z "$_ver"; then
## If empty, try date [fontforge]
Tested with both /bin/sh (which is a ksh here) and /usr/local/bin/bash
(bash-4.0.35).
Pick your choice.
Ciao,
Kili