Re: unexpected bash behaviour
> How come `time a.out > /dev/null` prints "time" output,
> while `time (a.out > /dev/null)` doesn't print anything at all.
> Shouldn't it be the other way around?
>
> Thanks
>
> Alec
[04:58:22 tmp]$ help time
time: time [-p] PIPELINE
Execute PIPELINE and print a summary of the real time, user CPU
time,
and system CPU time spent executing PIPELINE when it terminates.
The return status is the return status of PIPELINE. The `-p' option
prints the timing summary in a slightly different format. This uses
the value of the TIMEFORMAT variable as the output format.
times: times
Print the accumulated user and system times for processes run from
the shell.
[04:58:58 tmp]$
This explain the time a.out > /dev/null case. This is so because the
whole string a.out > /dev/null is executed and its execution time is
measured.
Do not know about time (a.out > /dev/null). It could be that time is
forced to exit as soon as a sub shell is forked and so it can not
measure the execution time of the sub process.
--
Shaul Karl
email: shaulka(at-no-spam)bezeqint.net
Please replace (at-no-spam) with an at - @ - character.
(at-no-spam) is meant for unsolicitate mail senders only.
Reply to: