automake-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] test defs: add subroutine for input unindenting


From: Peter Rosin
Subject: Re: [PATCH] test defs: add subroutine for input unindenting
Date: Fri, 18 Feb 2011 13:12:15 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7

Den 2011-02-17 19:18 skrev Stefano Lattarini:
> Hello Peter.
> 
> On Thursday 17 February 2011, Peter Rosin wrote:
>> Den 2011-02-15 21:19 skrev Ralf Wildenhues:
>>> It's a bit of a shame this uses a temp file though.  awk
>>> should be able to cope without (but be sure to try old
>>> Solaris awk if you go for it).
>>
>> Ahh, who needs awk? :-)
>>
>> [CUT]
>>
> Wow, this seems really clever! (I say "seems" because I must
> admit I haven't tried to read it in detail, nor to really
> understand it).

I think the terseness of the sed language is the biggest
difficulty.

> However ...
> 
>> Too much of a maintenance hassle?  You tell me.
>>
> ... I do think it's really too much of a maintenance hassle
> *for the use of the function we expect to do*.  If we were
> writing a library of general-purpose shell functions, I'd
> definitely choose your implementation over mine, but in the
> present situation I see no real advatange.  Sorry.

It's that thing with parallel execution, but I can agree that
there are no current users needing that.

Anyway, when I wrote the program I looked for a way to just
skip ahead to the next cycle, but didn't find how to do it.
Since then, I have realized that 'b' w/o argument does exactly
the thing I was looking for, so a slightly shorter program
follows (I also added a few anchors):

unindent ()
{
  sed '
    x
    :useit
    /./{
      G
      h
      s/\n.*$//
      x
      s/^x\(.*\)\n\1//
      s/^.*\n//
      b
    }
    g
    /^$/b
    s/^\([      ]*\).*/x\1/
    b useit'
}


> Anyway, Ralf has the final word here, so let's wait to hear
> from him too.

Yes, I will try my best not to spam the list with more versions of
this baby...

Cheers,
Peter



reply via email to

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