Using 'time' in an 'until' loop
- From: gazelle@xxxxxxxxxxxxxxxxxx (Kenny McCormack)
- Date: Sun, 29 Jul 2012 10:24:11 +0000 (UTC)
Something strange... I wrote:
until time someLongCommand;do sleep 10;done
This works fine without the 'time' - there is nothing wrong with
someLongCommand or anythiing like that.
But, with 'time', it errors on 'Command not found'.
It turns out the problem is that on the system this is running on, there is
no /usr/bin/time - only the shell builtin. But I am amazed that in an
'until' loop, builtins don't work. Is there any reason why that should be
so? All of my previous experience and reading indicate that there should
be problem with this.
There are, of course, a few workarounds. One would be to restructure the
code to not have the command inside the 'until' - that is, somehow run it
'normally', then use $? to test the return status. But that's ugly.
I ended up doing:
until sh -c 'time someLongCommand';do sleep 10;done
But I am not happy with it...
--
Faced with the choice between changing one's mind and proving that there is
no need to do so, almost everyone gets busy on the proof.
- John Kenneth Galbraith -
.
- Follow-Ups:
- Re: Using 'time' in an 'until' loop
- From: Ben Bacarisse
- Re: Using 'time' in an 'until' loop
- From: Christian Weisgerber
- Re: Using 'time' in an 'until' loop
- From: Janis Papanagnou
- Re: Using 'time' in an 'until' loop
- From: Kenny McCormack
- Re: Using 'time' in an 'until' loop
- Prev by Date: Re: trying to use a variable in a regex
- Next by Date: Re: trying to use a variable in a regex
- Previous by thread: trying to use a variable in a regex
- Next by thread: Re: Using 'time' in an 'until' loop
- Index(es):
Relevant Pages
|