bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: problems with AM_GNU_GETTEXT_VERSION


From: Bruno Haible
Subject: Re: problems with AM_GNU_GETTEXT_VERSION
Date: Sat, 19 Jan 2008 23:06:53 +0100
User-agent: KMail/1.5.4

Hi Eric,

> | ! xver=`cat "$configure_in" | grep '^AM_GNU_GETTEXT_VERSION(' | sed -n -e 
> "$sed_extract_AM_GNU_GETTEXT_VERSION_argument"p | sed -e 
> "$sed_remove_outer_brackets" | sed -e 1q`
> 
> Isn't that rather process-intensive?  You have a useless use of cat.  You
> should never need grep piped into sed; let sed's regex matching do the
> work instead.  Multiple invocations of sed can often be collapsed into a
> single invocation.
> ...
> What about:
> 
> xver=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ {
> ~  '"$sed_extract_AM_GNU_GETTEXT_VERSION_argument"'
> ~  '"$sed_remove_outer_brackets"'p
> ~  q
> }' "$configure_in"`

Your solution to the problem is certainly as correct as mine.

But I still prefer the code with multiple pipes, because

  - The number of spawned processes is irrelevant here: The code is not inside
    in a loop, it is executed only once per autopoint invocation.

  - The many pipes are good for debugging and maintenance. When the code does
    not do what it should do, in a particular situation, I can look at the
    output of the first pipe, then at the output of the second pipe, etc.
    and fix the one pipe that is not correct. You can't do that easily with
    a large sed invocation.

  - Also for maintainability: Use simple grep and simple sed where possible.
    I claim that many people know sed's s/.../.../ command syntax by heart
    while the use of braces is outside their 'sed' vocabulary. Try to make
    the code understandable to as many persons as possible. (This is also
    the reason why autopoint, gnulib-tool etc. are written as shell scripts,
    not as Lisp scripts - would have been my preference - or p*rl scripts
    - other people's preference.)

Bruno





reply via email to

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