[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] bootstrap: use a more consistent error reporting scheme.
From: |
Akim Demaille |
Subject: |
Re: [PATCH] bootstrap: use a more consistent error reporting scheme. |
Date: |
Tue, 10 Jul 2012 11:19:15 +0200 |
Le 10 juil. 2012 à 10:14, Jim Meyering a écrit :
>> + case $* in
>> + *$nl*) me_=$(printf "$me"|tr "$nl|" '??')
>
> Is it worth testing for both $nl and '|' ?
I tried to keep what you did about $nl in $me (it would break
the sed command). I used printf, since the \n from echo gave
a spurious ? at the end of $me.
And | is the separator for sed.
>> + printf "$warnf_format_" "$@" | sed "s|^|$me_: |" ;;
>> + *) printf "$me: $warnf_format_" "$@" ;;
>> + esac >&2
>> +}
>> +
>> +warnf_ '<%s>\n' "test1" 't
>> +e
>> +d
>> +2' t3 t54
>
> No test artifacts, please ;-)
Bummer. Thanks a lot…
Installed as follows.
From 4df9d155485595d7bae28d434a945f9c22dd1a71 Mon Sep 17 00:00:00 2001
From: Akim Demaille <address@hidden>
Date: Fri, 6 Jul 2012 15:01:53 +0200
Subject: [PATCH] bootstrap: let warn be like tests/init.sh's warn_
Reported by Jim Meyering.
* build-aux/bootstrap (warn): Remove, replaced by...
(warnf_, warn_): these.
Adjust callers.
Shorten messages that no longer fit in 80 columns.
---
ChangeLog | 9 +++++++++
build-aux/bootstrap | 47 ++++++++++++++++++++++++++++++++---------------
2 files changed, 41 insertions(+), 15 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 892eb16..d94f7b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2012-07-10 Akim Demaille <address@hidden>
+
+ bootstrap: let warn be like tests/init.sh's warn_
+ Reported by Jim Meyering.
+ * build-aux/bootstrap (warn): Remove, replaced by...
+ (warnf_, warn_): these.
+ Adjust callers.
+ Shorten messages that no longer fit in 80 columns.
+
2012-07-09 Bruno Haible <address@hidden>
getopt: Simplify after Emacs changed.
diff --git a/build-aux/bootstrap b/build-aux/bootstrap
index 1d61e5c..e00c8bbb 100755
--- a/build-aux/bootstrap
+++ b/build-aux/bootstrap
@@ -1,6 +1,6 @@
#! /bin/sh
# Print a version string.
-scriptversion=2012-07-06.11; # UTC
+scriptversion=2012-07-10.09; # UTC
# Bootstrap this package from checked-out sources.
@@ -77,15 +77,32 @@ Running without arguments will suffice in most cases.
EOF
}
-warn()
+# warnf_ FORMAT-STRING ARG1...
+warnf_ ()
{
- for i
- do
- echo "$i"
- done | sed -e "s/^/$me: /" >&2
+ warnf_format_=$1
+ shift
+ nl='
+'
+ case $* in
+ *$nl*) me_=$(printf "$me"|tr "$nl|" '??')
+ printf "$warnf_format_" "$@" | sed "s|^|$me_: |" ;;
+ *) printf "$me: $warnf_format_" "$@" ;;
+ esac >&2
+}
+
+# warn_ WORD1...
+warn_ ()
+{
+ # If IFS does not start with ' ', set it and emit the warning in a subshell.
+ case $IFS in
+ ' '*) warnf_ '%s\n' "$*";;
+ *) (IFS=' '; warn_ "$@");;
+ esac
}
-die() { warn "$@"; exit 1; }
+# die WORD1...
+die() { warn_ "$@"; exit 1; }
# Configuration.
@@ -335,8 +352,7 @@ grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])'
configure.ac \
grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
>/dev/null && found_aux_dir=yes
test $found_aux_dir = yes \
- || die "expected line not found in configure.ac. Add the following:" \
- " AC_CONFIG_AUX_DIR([$build_aux])"
+ || die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it"
# If $build_aux doesn't exist, create it now, otherwise some bits
# below will malfunction. If creating it, also mark it as ignored.
@@ -442,7 +458,7 @@ check_versions() {
automake-ng|aclocal-ng)
app=${app%-ng}
($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
- warn "Error: '$app' not found or not from Automake-NG"
+ warn_ "Error: '$app' not found or not from Automake-NG"
ret=1
continue
} ;;
@@ -452,20 +468,21 @@ check_versions() {
# so we have to rely on $? rather than get_version.
$app --version >/dev/null 2>&1
if [ 126 -le $? ]; then
- warn "Error: '$app' not found"
+ warn_ "Error: '$app' not found"
ret=1
fi
else
# Require app to produce a new enough version string.
inst_ver=$(get_version $app)
if [ ! "$inst_ver" ]; then
- warn "Error: '$app' not found"
+ warn_ "Error: '$app' not found"
ret=1
else
latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
if [ ! "$latest_ver" = "$inst_ver" ]; then
- warn "Error: '$app' version == $inst_ver is too old" \
- " '$app' version >= $req_ver is required"
+ warnf_ '%s\n' \
+ "Error: '$app' version == $inst_ver is too old" \
+ " '$app' version >= $req_ver is required"
ret=1
fi
fi
@@ -761,7 +778,7 @@ version_controlled_file() {
grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
grep '^/[^/]*/[0-9]' > /dev/null
else
- warn "no version control for $file?"
+ warn_ "no version control for $file?"
false
fi
}
--
1.7.11.1
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., (continued)
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Akim Demaille, 2012/07/06
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Jim Meyering, 2012/07/06
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Akim Demaille, 2012/07/06
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Jim Meyering, 2012/07/06
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Bruce Korb, 2012/07/06
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Eric Blake, 2012/07/09
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Eric Blake, 2012/07/09
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Jim Meyering, 2012/07/10
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Akim Demaille, 2012/07/10
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Jim Meyering, 2012/07/10
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme.,
Akim Demaille <=
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Jim Meyering, 2012/07/10
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Akim Demaille, 2012/07/10
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Jim Meyering, 2012/07/10
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Akim Demaille, 2012/07/06
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Stefano Lattarini, 2012/07/06
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Akim Demaille, 2012/07/06
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Stefano Lattarini, 2012/07/06
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Akim Demaille, 2012/07/06
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Jim Meyering, 2012/07/06
- Re: [PATCH] bootstrap: use a more consistent error reporting scheme., Paul Eggert, 2012/07/06