Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-10 Thread Jim Meyering
Akim Demaille wrote: > Le 10 juil. 2012 à 12:05, Jim Meyering a écrit : > >> Akim Demaille wrote: >> >>> 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 trie

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-10 Thread Akim Demaille
Le 10 juil. 2012 à 12:05, Jim Meyering a écrit : > Akim Demaille wrote: > >> 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 $n

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-10 Thread Jim Meyering
Akim Demaille wrote: > 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, sinc

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-10 Thread Akim Demaille
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 spurio

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-10 Thread Jim Meyering
Akim Demaille wrote: > Here is an updated proposal, that was taking into account > several comments made last week. Looks fine, modulo a question and test artifacts: Thanks! ... > -warn() > +# warnf_ FORMAT-STRING ARG1... > +warnf_ () > { > - for i > - do > -echo "$i" > - done | sed -e "s

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-10 Thread Akim Demaille
Hi all, Here is an updated proposal, that was taking into account several comments made last week. 0001-bootstrap-let-warn-be-like-tests-init.sh-s-warn_.patch Description: Binary data

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-09 Thread Jim Meyering
Akim Demaille wrote: > Le 6 juil. 2012 à 14:44, Jim Meyering a écrit : >> No, but if you think it's better, somehow... >> I meant that warnf would be a very thin wrapper around printf: >> >>$ printf '%s\n' a b c >>a >>b >>c >> >>> Or should warnf expect a single %s >> >> or multiple

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-09 Thread Eric Blake
On 07/09/2012 05:04 PM, Eric Blake wrote: >> -warn() >> +# warnf_ FORMAT-STRING ARG1... >> +warnf_ () >> { >> - for i >> - do >> -echo "$i" >> - done | sed -e "s/^/$me: /" >&2 > > This is broken if you invoke './bootstrap', since then $me contains / > and bootstrap complains: > > autorec

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-09 Thread Eric Blake
On 07/06/2012 07:11 AM, Akim Demaille wrote: > How about this? > > From 96b829fb08217060f20a6a56eddb1a952324fa35 Mon Sep 17 00:00:00 2001 > From: Akim Demaille > Date: Fri, 6 Jul 2012 15:01:53 +0200 > Subject: [PATCH] bootstrap: let warn be alike tests/init.sh's warn_ > > Reported by Jim Meyeri

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Thien-Thi Nguyen
() Jim Meyering () Fri, 06 Jul 2012 17:49:03 +0200 We want warnf '%s\n' a b c d to print this (as printf would do): $me: a $me: b $me: c $me: d With that added "%s: ", and with "$me" inserted into the list of arguments, we'd get this: $me: a

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Bruce Korb
On 07/06/12 06:11, Akim Demaille wrote: One other tiny nit that is helpful in a die() function: It isn't necessarily true that "die" always gets invoked from the main process. If it gets invoked from a subprocess for any of a variety of reasons, this: +die() { warn_ "$@"; exit 1; } won't work.

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Jim Meyering
Thien-Thi Nguyen wrote: > () Akim Demaille > () Fri, 6 Jul 2012 16:40:37 +0200 > >But we have to worry about ',' in $me, which is $0, not >its basename. Do you want me (Akim, not the variable) >to change me (the variable, not Akim; not that I am >immutable) to basename and use /

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Thien-Thi Nguyen
() Akim Demaille () Fri, 6 Jul 2012 16:40:37 +0200 But we have to worry about ',' in $me, which is $0, not its basename. Do you want me (Akim, not the variable) to change me (the variable, not Akim; not that I am immutable) to basename and use / in the sed command, instead of ','?

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Jim Meyering
Akim Demaille wrote: > Le 6 juil. 2012 à 16:09, Jim Meyering a écrit : > >> You're welcome to leave the pipe-to-sed. >> Worrying about an extra process when processing a diagnostic >> is probably a pre-optimization anyhow. Besides, then >> we don't have to worry about whether $me is printf-safe. >

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Akim Demaille
Le 6 juil. 2012 à 16:09, Jim Meyering a écrit : > You're welcome to leave the pipe-to-sed. > Worrying about an extra process when processing a diagnostic > is probably a pre-optimization anyhow. Besides, then > we don't have to worry about whether $me is printf-safe. But we have to worry about

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Paul Eggert
On 07/06/2012 07:09 AM, Jim Meyering wrote: > You're welcome to leave the pipe-to-sed. > Worrying about an extra process when processing a diagnostic > is probably a pre-optimization anyhow. ... unless the diagnostic is something like "program failed" due to lack of enough system resources to fork

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Jim Meyering
Akim Demaille wrote: > Le 6 juil. 2012 à 15:21, Stefano Lattarini a écrit : > >> Why not shave off the extra forks here? >> >>printf "$me: $warnf_format_" "$@" >&2 >> >> This shouldn't cause problems, unless '$me' contains '%' or '\' characters. > > Or end of line. Elsewhere, where I use simil

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Akim Demaille
Le 6 juil. 2012 à 15:54, Stefano Lattarini a écrit : > On 07/06/2012 03:28 PM, Akim Demaille wrote: >> >> Le 6 juil. 2012 à 15:21, Stefano Lattarini a écrit : >> >>> Why not shave off the extra forks here? >>> >>> printf "$me: $warnf_format_" "$@" >&2 >>> >>> This shouldn't cause problems,

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Stefano Lattarini
On 07/06/2012 03:28 PM, Akim Demaille wrote: > > Le 6 juil. 2012 à 15:21, Stefano Lattarini a écrit : > >> Why not shave off the extra forks here? >> >>printf "$me: $warnf_format_" "$@" >&2 >> >> This shouldn't cause problems, unless '$me' contains '%' or '\' characters. > > Or end of line.

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Akim Demaille
Le 6 juil. 2012 à 15:21, Stefano Lattarini a écrit : > Why not shave off the extra forks here? > >printf "$me: $warnf_format_" "$@" >&2 > > This shouldn't cause problems, unless '$me' contains '%' or '\' characters. Or end of line. Elsewhere, where I use similar routines, it is useful to

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Jim Meyering
Akim Demaille wrote: > Le 6 juil. 2012 à 14:44, Jim Meyering a écrit : > >> No, but if you think it's better, somehow... >> I meant that warnf would be a very thin wrapper around printf: >> >>$ printf '%s\n' a b c >>a >>b >>c >> >>> Or should warnf expect a single %s >> >> or multip

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Stefano Lattarini
On 07/06/2012 03:11 PM, Akim Demaille wrote: > > --- 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-06.13; # UTC > > # Bootstrap this package from checked-out sources. >

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Akim Demaille
Le 6 juil. 2012 à 14:44, Jim Meyering a écrit : > No, but if you think it's better, somehow... > I meant that warnf would be a very thin wrapper around printf: > >$ printf '%s\n' a b c >a >b >c > >> Or should warnf expect a single %s > > or multiple %-directives: > >$ prin

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Akim Demaille
Le 6 juil. 2012 à 14:44, Jim Meyering a écrit : > No, but if you think it's better, somehow... > I meant that warnf would be a very thin wrapper around printf: > >$ printf '%s\n' a b c >a >b >c > >> Or should warnf expect a single %s > > or multiple %-directives: > >$ prin

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Stefano Lattarini
On 07/06/2012 02:37 PM, Akim Demaille wrote: > Le 6 juil. 2012 à 14:24, Jim Meyering a écrit : > >>warnf '%s\n' "Error: '$app' version == $inst_ver is too old" \ >> " '$app' version >= $req_ver is required" > > Don't you mean warnf '%s\n%s\n'? Or should warnf expect a si

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Jim Meyering
Akim Demaille wrote: > Le 6 juil. 2012 à 14:24, Jim Meyering a écrit : > >> Akim Demaille wrote: >>> Le 6 juil. 2012 à 13:56, Jim Meyering a écrit : >>> Um... this is a good reason to post an adjusted patch. What I meant was that it is fine to continue to print that diagnostic on one

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Akim Demaille
Le 6 juil. 2012 à 14:24, Jim Meyering a écrit : > Akim Demaille wrote: >> Le 6 juil. 2012 à 13:56, Jim Meyering a écrit : >> >>> Um... this is a good reason to post an adjusted patch. >>> What I meant was that it is fine to continue to print that diagnostic >>> on one line, but not using echo; u

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Jim Meyering
Akim Demaille wrote: > Le 6 juil. 2012 à 13:56, Jim Meyering a écrit : > >> Um... this is a good reason to post an adjusted patch. >> What I meant was that it is fine to continue to print that diagnostic >> on one line, but not using echo; using the new "warn". >> >> It should use warn, and warn sh

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Akim Demaille
Le 6 juil. 2012 à 13:56, Jim Meyering a écrit : > Um... this is a good reason to post an adjusted patch. > What I meant was that it is fine to continue to print that diagnostic > on one line, but not using echo; using the new "warn". > > It should use warn, and warn should be defined as in init.

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Jim Meyering
Akim Demaille wrote: > Le 6 juil. 2012 à 12:01, Jim Meyering a écrit : > >> Akim Demaille wrote: >> >>> It is also very useful to have a single command that issues >>> several lines. This is the case here for instance: >> >> I would debate the "very useful" part ;-) >> How about "might be nice, in

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Akim Demaille
Le 6 juil. 2012 à 12:01, Jim Meyering a écrit : > Akim Demaille wrote: > >> It is also very useful to have a single command that issues >> several lines. This is the case here for instance: > > I would debate the "very useful" part ;-) > How about "might be nice, in the rare event someone sees

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Jim Meyering
Akim Demaille wrote: > Hi Jim! > > Le 6 juil. 2012 à 11:43, Jim Meyering a écrit : > >> Thanks for the patch. >> >> Those all look like improvements, but I'd prefer that >> you change the name s/stderr/warn/: "stderr" is not normally >> used as a verb. > > OK. I avoided "warn" because I felt it w

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Akim Demaille
Hi Jim! Le 6 juil. 2012 à 11:43, Jim Meyering a écrit : > Thanks for the patch. > > Those all look like improvements, but I'd prefer that > you change the name s/stderr/warn/: "stderr" is not normally > used as a verb. OK. I avoided "warn" because I felt it would be valid for it to include a "

Re: [PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Jim Meyering
Akim Demaille wrote: > Independently of the other thread we're having about set -e, > I had refactored bootstrap a bit. > -8<--- > > * build-aux/bootstrap (stderr, die): New. > Use them. > --- > build-aux/bootstrap | 94 > ++--- > 1 file changed, 47

[PATCH] bootstrap: use a more consistent error reporting scheme.

2012-07-06 Thread Akim Demaille
Independently of the other thread we're having about set -e, I had refactored bootstrap a bit. -8<--- * build-aux/bootstrap (stderr, die): New. Use them. --- build-aux/bootstrap | 94 ++--- 1 file changed, 47 insertions(+), 47 deletions(-) diff --g