Using 'time' in an 'until' loop



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 -

.



Relevant Pages

  • Re: Using time in an until loop
    ... someLongCommand or anythiing like that. ... But, with 'time', it errors on 'Command not found'. ... until sh -c 'time someLongCommand';do sleep 10;done ... Obvious money transfers between the taxpayers and Bush's moneyed ...
    (comp.unix.shell)
  • Re: Using time in an until loop
    ... someLongCommand or anythiing like that. ... But, with 'time', it errors on 'Command not found'. ... until sh -c 'time someLongCommand';do sleep 10;done ... reserved word -- part of the syntax of a pipeline. ...
    (comp.unix.shell)
  • Re: OT Shell tricks: Ill kill you later
    ... The ps side is actually simplified from the command I've been using. ... The sleep actually provides additional insurance. ... > That avoids the collateral damage from similarly named processes. ... but will be pretty safe in practice. ...
    (Debian-User)
  • Re: sleep command for Expect
    ... > Could it be possible that the Expect interpreter on my system has been ... I assume that the sleep ... I just tried this test and it showed that sleep is a command available ... pid proc prompt1 prompt2 puts pwd read regexp regsub remove_nulls ...
    (comp.lang.tcl)
  • Re: Copy a file accross a LAN during startup
    ... Do you have a specific sleep program you ... In command languages sleep is usually a counter (you aren't specifying any ... >>> do this and put it in the startup folder of her computer. ... >>> file across the LAN. ...
    (microsoft.public.win2000.cmdprompt.admin)