[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] question about command time
From: |
Bob Proulx |
Subject: |
Re: [Help-bash] question about command time |
Date: |
Sun, 20 Jan 2013 22:08:06 -0700 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
MaShimiao wrote:
> I read bash's changelog. And it says in version 4.2, posix parsing
> changes to allow '! time command' and multiple consecutive instance
> of '!'(which toggle) and 'time'(which have no cumulative effect).
>
> In bash-4.1 we also can use '! time command', just it outputs
> different words
With bash-4.1 when you call
! time command
because of the ! you are getting
/usr/bin/time command
and then the exit code is being negated. If you call time multiple
times on the command line then it is invoked multiple times.
> with bash-4.2.
With bash-4.2 you are getting the builtin time command in both cases.
And it is only invoked once. That is the improvement.
> And I don't understand "multiple consecutive instance of '!'(which
> toggle) and 'time'(which have no cumulative effect)". What actually
> does it want to do?
Think about these invocations and try them on the different versions:
sleep 0.1
time sleep 0.1
! sleep 0.1
! time sleep 0.1
! ! time sleep 0.1
! time ! time sleep 0.1
! ! ! ! time sleep 0.1
time ! sleep 0.1
! time ! sleep 0.1
! time ! time sleep 0.1
! time ! ! sleep 0.1
! time ! ! sleep 0.1
In the old version time would be run multiple times and as an external
command. In the new version the line is scanned first and time is
only run once.
Bob