Red Hat Bugzilla – Bug 443059
time & /usr/bin/time confusion
Last modified: 2016-05-31 21:36:49 EDT
There is quite a bad confusion between /usr/bin/time command and bash time
reserved word. As as looked I am not the first one, who encountered the problem:
bug 27200: time <command> works, but time <options> command doesn't
bug 49482: time does not take arguments
bug 91540: Time ignores --format
bug 142474: "time" command does not function according to man page
I suggest to modify the time man page to include a warning about shell reserved
word time not to be confused with /usr/bin/time. Perhaps something like this:
Please do not confuse "time" command with shell reserved word "time" which does
not take any options and reports time consumed by executing a pipeline (for more
see: man bash, section pipelines).
Confusion example (motivation):
# man time
[oh, there is --format option, great! that's exactly what i need!]
# time -f '%E' sleep 1
-bash: -f: command not found
# which time
# time --version
-bash: --version: command not found
... after half an hour? hour?
# type time
time is a shell keyword
Probably not a bug. It is confusing, but if anyone wants to know what will be run, should use `command -v time'. Command `which' don't see shell builtins.
On the other hand `man time' should show the right page. The same for `echo'...
I see it's not a bug, but a confusion caused by naming two functions which behave differently with the same name. And because of this (plus the fact that people run into this confusion again and again) this should be documented in time man page.
Either by including the warning mentioned in the comment #0, or at least mentioning bash in SEE ALSO section. I would prefer the first, more descriptive option, as finding the time shell keyword in pipelines section of bash large man page is not very intuitive either.
Upstream maintainer looked to this issue and do some changes to 3.14 so I think there is no problem to backport them to rhel5 version, because this issue could be quite confusing.
Note: some shells (e.g., bash(1)) have a built-in time command
that provides less functionality than the command described
here. To access the real command, you may need to specify its
pathname (something like /usr/bin/time).
That's great! Thanks for pointing this out.
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.