Hello,

Would it make sense to add to 'time' builtin a way to measure how long
a file descriptor is been kept open?  Something like this.

-- snip
#!/bin/bash
exec 42>&0
time --file-descriptor 42
sleep 10
exec 42>&-
-- snip

$ ./above_script.sh
real    0m10.012s
user    0m0.000s
sys     0m0.000s

This idea came to my mind while writing a script that runs multiple
commands, and I simply wanted to know how long they are busy.  I am
aware alternatives exist, but they can get a bit tricky if one wants to
have multiple measurements going on simultaneously.  For example:

exec 42>&0
time --file-descriptor 42
for i in items; in
        exec 52>&0
        time --file-descriptor 52
        echo "processing $i"
        [...]
        echo "item $i took"
        exec 52>&-
done
echo 'all together took:'
exec 42>&-

What do you think, useful feature or unnecessary bloat?

-- 
Sami Kerola
http://www.iki.fi/kerolasa/

Reply via email to