Anonymous | Login | 2024-09-16 22:44 UTC |
Main | My View | View Issues | Change Log | Docs |
Viewing Issue Simple Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||
ID | Category | Severity | Type | Date Submitted | Last Update | ||
0001051 | [1003.1(2013)/Issue7+TC1] Shell and Utilities | Editorial | Omission | 2016-05-04 14:30 | 2017-06-08 15:08 | ||
Reporter | stephane | View Status | public | ||||
Assigned To | |||||||
Priority | normal | Resolution | Duplicate | ||||
Status | Closed | ||||||
Name | Stephane Chazelas | ||||||
Organization | |||||||
User Reference | |||||||
Section | "time" utility | ||||||
Page Number | 3259 | ||||||
Line Number | 109327 | ||||||
Interp Status | --- | ||||||
Final Accepted Text | |||||||
Summary | 0001051: stderr redirection of the "time" utility | ||||||
Description |
ksh, pdksh/mksh, bash and zsh implement "time" as a keyword, where the syntax is: time <pipeline> Where pipeline is as defined in the shell grammar. Any redirection in that <pipeline> is considered to be part of the <pipeline> to be timed (with the exception of time (cmd) > redir in bash which seems to be an accident of implementation). The timing statistics are issued on the shell's stderr regardless of the stderr redirection made in the <pipeline> (with the exception of that bash corner case). That "time" keyword is recognised as such only when it's the first word of a pipeline or pipesequence or follows "!". bash has a further restriction that it cannot be used inside a pipeline. For instance in these cases, time is not recognised as a keyword E=x time ls <&3 time ls # except in zsh and in bash cmd1 | time cmd2 | cmd3 # other shells time "cmd2 | cmd3" When "time" is not considered as a keyword, then generally the "time" command from the filesystem is invoked ("a=1 time uname" causes a syntax error in zsh). There has been an attempt to cover for that case in the spec but it is incomplete. > When time is used as part of a pipeline, the times reported > are unspecified, except when it is the sole command within a > grouping command (see Section 2.9.4.1, on page 2344) in that > pipeline. It doesn't clarify what is meant by "pipeline". If it's by the grammar definition or 2.9.2, then that's every command. "time" can't be but to be used as part of such a pipeline. Even if it means a pipe lines with at least 2 commands, we'd still need to clarify what should happen for stderr redirections in: { time cmd 2> file; } | ... Note that all implementations except zsh seem to treat 2> file time cmd and even 2> file time cmd | cmd2 or cmd1 | 2>&1 time cmd | cmd3 the same (and time cmd only by invoking the filesytem's "cmd"). ksh93 also stops "time" being considered as a keyword when called with "-p". |
||||||
Desired Action |
Change the wording so "pipeline" becomes a "pipeline as per 2.9.2 with more than one command part". Mention that redirection of stderr may not affect the timing statistics output if the redirection operator appears on the right of the "time" word in the time command. It may be worth mentioning. <any-redirection> time cmd as a portable (ignoring zsh's time for now which is not POSIX compliant anyway) way to force "time" to behave (be parsed) as a normal utility. |
||||||
Tags | No tags attached. | ||||||
Attached Files | |||||||
|
Relationships | |||||||
|
There are no notes attached to this issue. |
Mantis 1.1.6[^] Copyright © 2000 - 2008 Mantis Group |