[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Modernize, improve and/or extend tests `colon*.test.
From: |
Stefano Lattarini |
Subject: |
Re: [PATCH] Modernize, improve and/or extend tests `colon*.test. |
Date: |
Sun, 8 Aug 2010 18:22:00 +0200 |
User-agent: |
KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; ) |
At Sunday 08 August 2010, Ralf Wildenhues wrote:
> * Stefano Lattarini wrote on Sun, Aug 08, 2010 at 06:06:04PM CEST:
> > At Sunday 08 August 2010, Ralf Wildenhues wrote:
> > > No. You save a fork with
> > >
> > > foo ()
> > > {
> > >
> > > ...
> > > foo_result=bar
> > >
> > > }
> > >
> > > foo ARG...
> > > test "$foo_result" = ...
> >
> > Yes, but how do you get foo_result in our case? ;-)
>
> With sed, of course.
Exactly! So:
foo() { foo_result=`sed ...`; }
foo; bar=$foo_result;
instead of:
foo() { sed ...; }
bar=`foo`
Where is the significant improvement?
> > Or am I missing something?
>
> I think you are. You proposed
> result=`foo ...`
> test "$result" = ...
> which is an extra fork over the above, regardless of what foo does
> internally.
Even considering my latest example above?
I'd like to sort this out, since if I am mistaken it means that I'm
probably misunderstanding something important...
Regards,
Stefano
P.S. I'm delibrately ignoring that we might also want to just
redirect the output of foo() to a file, which means that:
foo() { foo_result=`sed ...`; }
would lead us to extra useless forks *and* to extra coding
indirections, i.e.:
foo; echo "$foo_result" > file
instead of:
foo > file
- Re: [PATCH] Modernize, improve and/or extend tests `colon*.test., (continued)
- Re: [PATCH] Modernize, improve and/or extend tests `colon*.test., Stefano Lattarini, 2010/08/08
- Re: [PATCH] Modernize, improve and/or extend tests `colon*.test., Ralf Wildenhues, 2010/08/08
- Re: [PATCH] Modernize, improve and/or extend tests `colon*.test., Stefano Lattarini, 2010/08/08
- Re: [PATCH] Modernize, improve and/or extend tests `colon*.test., Ralf Wildenhues, 2010/08/08
- Re: [PATCH] Modernize, improve and/or extend tests `colon*.test., Stefano Lattarini, 2010/08/08
- Re: [PATCH] Modernize, improve and/or extend tests `colon*.test., Ralf Wildenhues, 2010/08/08
- Re: [PATCH] Modernize, improve and/or extend tests `colon*.test., Stefano Lattarini, 2010/08/08
- Re: [PATCH] Modernize, improve and/or extend tests `colon*.test., Ralf Wildenhues, 2010/08/08
- Re: [PATCH] Modernize, improve and/or extend tests `colon*.test., Stefano Lattarini, 2010/08/08
- Re: [PATCH] Modernize, improve and/or extend tests `colon*.test., Ralf Wildenhues, 2010/08/08
- Re: [PATCH] Modernize, improve and/or extend tests `colon*.test.,
Stefano Lattarini <=
- Re: [PATCH] Modernize, improve and/or extend tests `colon*.test., Ralf Wildenhues, 2010/08/08
- Re: [PATCH] Modernize, improve and/or extend tests `colon*.test., Stefano Lattarini, 2010/08/08
- avoiding forks in shell scripts (was: [PATCH] Modernize, improve and/or extend tests `colon*.test.), Ralf Wildenhues, 2010/08/08
- Re: avoiding forks in shell scripts (was: [PATCH] Modernize, improve and/or extend tests `colon*.test.), Stefano Lattarini, 2010/08/08