bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Jim Meyering
Subject: Re: [PATCH] bootstrap: use a more consistent error reporting scheme.
Date: Fri, 06 Jul 2012 17:18:41 +0200

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.
>
> 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 ','?
>
> # warnf_ FORMAT-STRING ARG1...
> warnf_ ()
> {
>   warnf_format_=$1
>   shift
>   printf "$warnf_format_" "$@" | sed "s,^,$me: ," >&2
> }

Good point.
In that case, we might as well do it right, along the lines Paul
suggested, maybe like this:

warnf_ ()
{
  warnf_format_=$1
  shift
  nl='
'
  case $me in
    *[$nl\\%]*) me=$(echo "$me"|tr "$nl" '?')
       printf "$warnf_format_" "$@" | sed "s!^!$me: !" ;;
    *) printf "$me: $warnf_format_" "$@" ;;
  esac >&2
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]