[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Problem with time command



In <[🔎] 4D9C342A.1090008@shadowcat.co.uk>, Chris Jackson wrote:
>Boyd Stephen Smith Jr. wrote:
>> GNU time 1.7
>> bss@dellbuntu:~$ type time
>> time is a shell keyword
>> 
>> (Bash has a time "builtin" that you should avoid if you want to use the
>> time binary.)
>
>Actually it's a keyword not a builtin.

That's why I used quotes.  For most purposes it can be treated like a shell 
builtin, but it's not really one.

Shell keywords are part of it's parser syntax, and may or may not be 
valid/recognized everywhere a command.  Shell builtins are not part of the 
parser syntax, but are simply "found" before any binary in the PATH.  Shell 
special builtins modify properties of the shell process, so they can't be 
simply executed by fork/exec and are allowed to exit the shell in certain 
failure cases.

In this particular case, "time" isn't recognized as a keyword except as the 
first part of a pipeline.  When it is not recognized as a keyword, the time 
binary is used:
bss@monster:~$ time echo | time --version
GNU time 1.7

real    0m0.002s
user    0m0.000s
sys     0m0.000s
bss@monster:~$ # or even ...
bss@monster:~$ time time --version
GNU time 1.7

real    0m0.002s
user    0m0.000s
sys     0m0.000s

-- 
Boyd Stephen Smith Jr.                   ,= ,-_-. =.
bss@iguanasuicide.net                   ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy         `-'(. .)`-'
http://iguanasuicide.net/                    \_/

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: