How can we make `time` apply to a pipeline or its component? [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
-2
down vote
favorite
This question already has an answer here:
How can I time a pipe?
3 answers
Is each `time` in these examples a keyword or `/usr/bin/time`?
3 answers
time command1 | command2
Does time
apply to command1
or command1 | command2
? If your answer is one of the two, how would you specify the other?
Could you explain your answer based on the grammar of bash or how the shell interprets the command?
When the shell parses the command, does it recognize time
as a reserved word before recognizing |
as a control operator? Does the order between recognizing time
as a reserved word and recognizing |
as a control operator determines whether time
applies to command1
or command1 | command2
?
Thanks.
bash pipe time
marked as duplicate by muru, vonbrand, Romeo Ninov, G-Man, Jesse_b May 19 at 13:20
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
-2
down vote
favorite
This question already has an answer here:
How can I time a pipe?
3 answers
Is each `time` in these examples a keyword or `/usr/bin/time`?
3 answers
time command1 | command2
Does time
apply to command1
or command1 | command2
? If your answer is one of the two, how would you specify the other?
Could you explain your answer based on the grammar of bash or how the shell interprets the command?
When the shell parses the command, does it recognize time
as a reserved word before recognizing |
as a control operator? Does the order between recognizing time
as a reserved word and recognizing |
as a control operator determines whether time
applies to command1
or command1 | command2
?
Thanks.
bash pipe time
marked as duplicate by muru, vonbrand, Romeo Ninov, G-Man, Jesse_b May 19 at 13:20
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
From your previous question: the accepted answer's second line is: "This is possible because the time built-in takes a pipeline as its arguments", and the third answer: "time is a shell keyword".
â muru
May 18 at 2:26
@muru That is a different question. My question here is whethertime
applies to the pipeline or just its first component.
â Tim
May 18 at 3:50
1
And the part of "the time built-in takes a pipeline as its arguments" you're having trouble understanding is?
â muru
May 18 at 3:51
"Does the order determines whethertime
applies tocommand1
orcommand1 | command2
?" The "order" of what? I'm writting an answer so I'd want to know what you meant by this.
â nxnev
May 18 at 4:11
add a comment |Â
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
This question already has an answer here:
How can I time a pipe?
3 answers
Is each `time` in these examples a keyword or `/usr/bin/time`?
3 answers
time command1 | command2
Does time
apply to command1
or command1 | command2
? If your answer is one of the two, how would you specify the other?
Could you explain your answer based on the grammar of bash or how the shell interprets the command?
When the shell parses the command, does it recognize time
as a reserved word before recognizing |
as a control operator? Does the order between recognizing time
as a reserved word and recognizing |
as a control operator determines whether time
applies to command1
or command1 | command2
?
Thanks.
bash pipe time
This question already has an answer here:
How can I time a pipe?
3 answers
Is each `time` in these examples a keyword or `/usr/bin/time`?
3 answers
time command1 | command2
Does time
apply to command1
or command1 | command2
? If your answer is one of the two, how would you specify the other?
Could you explain your answer based on the grammar of bash or how the shell interprets the command?
When the shell parses the command, does it recognize time
as a reserved word before recognizing |
as a control operator? Does the order between recognizing time
as a reserved word and recognizing |
as a control operator determines whether time
applies to command1
or command1 | command2
?
Thanks.
This question already has an answer here:
How can I time a pipe?
3 answers
Is each `time` in these examples a keyword or `/usr/bin/time`?
3 answers
bash pipe time
edited May 18 at 4:20
asked May 18 at 2:21
Tim
22.6k63222401
22.6k63222401
marked as duplicate by muru, vonbrand, Romeo Ninov, G-Man, Jesse_b May 19 at 13:20
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by muru, vonbrand, Romeo Ninov, G-Man, Jesse_b May 19 at 13:20
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
From your previous question: the accepted answer's second line is: "This is possible because the time built-in takes a pipeline as its arguments", and the third answer: "time is a shell keyword".
â muru
May 18 at 2:26
@muru That is a different question. My question here is whethertime
applies to the pipeline or just its first component.
â Tim
May 18 at 3:50
1
And the part of "the time built-in takes a pipeline as its arguments" you're having trouble understanding is?
â muru
May 18 at 3:51
"Does the order determines whethertime
applies tocommand1
orcommand1 | command2
?" The "order" of what? I'm writting an answer so I'd want to know what you meant by this.
â nxnev
May 18 at 4:11
add a comment |Â
From your previous question: the accepted answer's second line is: "This is possible because the time built-in takes a pipeline as its arguments", and the third answer: "time is a shell keyword".
â muru
May 18 at 2:26
@muru That is a different question. My question here is whethertime
applies to the pipeline or just its first component.
â Tim
May 18 at 3:50
1
And the part of "the time built-in takes a pipeline as its arguments" you're having trouble understanding is?
â muru
May 18 at 3:51
"Does the order determines whethertime
applies tocommand1
orcommand1 | command2
?" The "order" of what? I'm writting an answer so I'd want to know what you meant by this.
â nxnev
May 18 at 4:11
From your previous question: the accepted answer's second line is: "This is possible because the time built-in takes a pipeline as its arguments", and the third answer: "time is a shell keyword".
â muru
May 18 at 2:26
From your previous question: the accepted answer's second line is: "This is possible because the time built-in takes a pipeline as its arguments", and the third answer: "time is a shell keyword".
â muru
May 18 at 2:26
@muru That is a different question. My question here is whether
time
applies to the pipeline or just its first component.â Tim
May 18 at 3:50
@muru That is a different question. My question here is whether
time
applies to the pipeline or just its first component.â Tim
May 18 at 3:50
1
1
And the part of "the time built-in takes a pipeline as its arguments" you're having trouble understanding is?
â muru
May 18 at 3:51
And the part of "the time built-in takes a pipeline as its arguments" you're having trouble understanding is?
â muru
May 18 at 3:51
"Does the order determines whether
time
applies to command1
or command1 | command2
?" The "order" of what? I'm writting an answer so I'd want to know what you meant by this.â nxnev
May 18 at 4:11
"Does the order determines whether
time
applies to command1
or command1 | command2
?" The "order" of what? I'm writting an answer so I'd want to know what you meant by this.â nxnev
May 18 at 4:11
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
time command1 | command2
Does
time
apply tocommand1
orcommand1 | command2
? If your answer is one of the two, how would you specify the other?
In Bash:
time
is a reserved word- It applies to pipelines
In POSIX:
time
is an external utility- It applies to simple commands
In Bash and other shells with a time
reserved word, time
applies to the entire pipeline (command1 | command2
). In shells without a time
reserved word, time
applies to command1
.
However, in Bash you can force time
to apply to command1
running command time command1 | command2
(this one will run the external utility if it's available), time command1; | command2
(this one is POSIX-compliant) or time command1 | command2
(or any other variant where time
is quoted, this will also run the external utility; thanks ilkkachu!).
Q: Could you explain your answer based on the grammar of bash or how the shell interprets the command?
Bash's manual explains this in the 3.2.2 Pipelines chapter:
The format for a pipeline is
[time [-p]] [!] command1 [ | or |& command2 ] â¦
The reserved word
time
causes timing statistics to be printed for the pipeline once it finishes.
And POSIX in time
's manual:
time [-p] utility [argument...]
The
time
utility shall invoke the utility named by theutility
operand with arguments supplied as theargument
operands and write a message to standard error that lists timing statistics for the utility.
Q: When the shell parses the command, does it recognize
time
as a reserved word before recognizing|
as a control operator?
Bash's manual says:
The following is a brief description of the shellâÂÂs operation when it reads and executes a command. Basically, the shell does the following:
Reads its input from a file (see Shell Scripts), from a string supplied as an argument to the
-c
invocation option (see Invoking Bash), or from the userâÂÂs terminal.
Breaks the input into words and operators, obeying the quoting rules described in Quoting. These tokens are separated by
metacharacters
. Alias expansion is performed by this step (see Aliases).
Parses the tokens into simple and compound commands (see Shell Commands).
Performs the various shell expansions (see Shell Expansions), breaking the expanded tokens into lists of filenames (see Filename Expansion) and commands and arguments.
Performs any necessary redirections (see Redirections) and removes the redirection operators and their operands from the argument list.
Executes the command (see Executing Commands).
Optionally waits for the command to complete and collects its exit status (see Exit Status).
So, as far as I understand, reserved words and operators are recognized as such basically at the same time (2nd step).
Q: Does the order between recognizing
time
as a reserved word and recognizing|
as a control operator determines whethertime
applies tocommand1
orcommand1 | command2
?
The Bash's time
reserved word applies to pipelines and the POSIX's time
external utility applies to simple commands, it's not a matter of recognition order.
1
As I noted in another comment, POSIX allowstime
to be a keyword.
â muru
May 18 at 6:14
1
Isn'tcommand
also POSIX? Also, in Bash, you could quote the keyword, so it won't recognize it as such:time foo
runs the external commandtime
â ilkkachu
May 18 at 6:16
@muru Yes, but my point is that POSIX does not requiretime
to be a keyword. In the same page both you and I linked says: "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 in that pipeline". And, in the "unspecified" definition: "The value or behavior may vary among implementations that conform to POSIX.1-2017. An application should not rely on the existence or validity of the value or behavior.". That's why I wrote: "In shells without atime
reserved word,time
applies tocommand1
".
â nxnev
May 18 at 6:36
@nxnev that maybe your point, but you have repeatedly said that POSIXtime
has to be external. My point is that POSIX makes no such requirement.
â muru
May 18 at 6:38
@ilkkachu 1)command
is POSIX, but IMHO using that workaround in a shell wheretime
is not a keyword but an external command is redundant; using it in Bash (and KSH, and ZSH, ...) makes more sense. 2) That's right, just added that example. Thanks!
â nxnev
May 18 at 6:38
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
time command1 | command2
Does
time
apply tocommand1
orcommand1 | command2
? If your answer is one of the two, how would you specify the other?
In Bash:
time
is a reserved word- It applies to pipelines
In POSIX:
time
is an external utility- It applies to simple commands
In Bash and other shells with a time
reserved word, time
applies to the entire pipeline (command1 | command2
). In shells without a time
reserved word, time
applies to command1
.
However, in Bash you can force time
to apply to command1
running command time command1 | command2
(this one will run the external utility if it's available), time command1; | command2
(this one is POSIX-compliant) or time command1 | command2
(or any other variant where time
is quoted, this will also run the external utility; thanks ilkkachu!).
Q: Could you explain your answer based on the grammar of bash or how the shell interprets the command?
Bash's manual explains this in the 3.2.2 Pipelines chapter:
The format for a pipeline is
[time [-p]] [!] command1 [ | or |& command2 ] â¦
The reserved word
time
causes timing statistics to be printed for the pipeline once it finishes.
And POSIX in time
's manual:
time [-p] utility [argument...]
The
time
utility shall invoke the utility named by theutility
operand with arguments supplied as theargument
operands and write a message to standard error that lists timing statistics for the utility.
Q: When the shell parses the command, does it recognize
time
as a reserved word before recognizing|
as a control operator?
Bash's manual says:
The following is a brief description of the shellâÂÂs operation when it reads and executes a command. Basically, the shell does the following:
Reads its input from a file (see Shell Scripts), from a string supplied as an argument to the
-c
invocation option (see Invoking Bash), or from the userâÂÂs terminal.
Breaks the input into words and operators, obeying the quoting rules described in Quoting. These tokens are separated by
metacharacters
. Alias expansion is performed by this step (see Aliases).
Parses the tokens into simple and compound commands (see Shell Commands).
Performs the various shell expansions (see Shell Expansions), breaking the expanded tokens into lists of filenames (see Filename Expansion) and commands and arguments.
Performs any necessary redirections (see Redirections) and removes the redirection operators and their operands from the argument list.
Executes the command (see Executing Commands).
Optionally waits for the command to complete and collects its exit status (see Exit Status).
So, as far as I understand, reserved words and operators are recognized as such basically at the same time (2nd step).
Q: Does the order between recognizing
time
as a reserved word and recognizing|
as a control operator determines whethertime
applies tocommand1
orcommand1 | command2
?
The Bash's time
reserved word applies to pipelines and the POSIX's time
external utility applies to simple commands, it's not a matter of recognition order.
1
As I noted in another comment, POSIX allowstime
to be a keyword.
â muru
May 18 at 6:14
1
Isn'tcommand
also POSIX? Also, in Bash, you could quote the keyword, so it won't recognize it as such:time foo
runs the external commandtime
â ilkkachu
May 18 at 6:16
@muru Yes, but my point is that POSIX does not requiretime
to be a keyword. In the same page both you and I linked says: "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 in that pipeline". And, in the "unspecified" definition: "The value or behavior may vary among implementations that conform to POSIX.1-2017. An application should not rely on the existence or validity of the value or behavior.". That's why I wrote: "In shells without atime
reserved word,time
applies tocommand1
".
â nxnev
May 18 at 6:36
@nxnev that maybe your point, but you have repeatedly said that POSIXtime
has to be external. My point is that POSIX makes no such requirement.
â muru
May 18 at 6:38
@ilkkachu 1)command
is POSIX, but IMHO using that workaround in a shell wheretime
is not a keyword but an external command is redundant; using it in Bash (and KSH, and ZSH, ...) makes more sense. 2) That's right, just added that example. Thanks!
â nxnev
May 18 at 6:38
add a comment |Â
up vote
3
down vote
accepted
time command1 | command2
Does
time
apply tocommand1
orcommand1 | command2
? If your answer is one of the two, how would you specify the other?
In Bash:
time
is a reserved word- It applies to pipelines
In POSIX:
time
is an external utility- It applies to simple commands
In Bash and other shells with a time
reserved word, time
applies to the entire pipeline (command1 | command2
). In shells without a time
reserved word, time
applies to command1
.
However, in Bash you can force time
to apply to command1
running command time command1 | command2
(this one will run the external utility if it's available), time command1; | command2
(this one is POSIX-compliant) or time command1 | command2
(or any other variant where time
is quoted, this will also run the external utility; thanks ilkkachu!).
Q: Could you explain your answer based on the grammar of bash or how the shell interprets the command?
Bash's manual explains this in the 3.2.2 Pipelines chapter:
The format for a pipeline is
[time [-p]] [!] command1 [ | or |& command2 ] â¦
The reserved word
time
causes timing statistics to be printed for the pipeline once it finishes.
And POSIX in time
's manual:
time [-p] utility [argument...]
The
time
utility shall invoke the utility named by theutility
operand with arguments supplied as theargument
operands and write a message to standard error that lists timing statistics for the utility.
Q: When the shell parses the command, does it recognize
time
as a reserved word before recognizing|
as a control operator?
Bash's manual says:
The following is a brief description of the shellâÂÂs operation when it reads and executes a command. Basically, the shell does the following:
Reads its input from a file (see Shell Scripts), from a string supplied as an argument to the
-c
invocation option (see Invoking Bash), or from the userâÂÂs terminal.
Breaks the input into words and operators, obeying the quoting rules described in Quoting. These tokens are separated by
metacharacters
. Alias expansion is performed by this step (see Aliases).
Parses the tokens into simple and compound commands (see Shell Commands).
Performs the various shell expansions (see Shell Expansions), breaking the expanded tokens into lists of filenames (see Filename Expansion) and commands and arguments.
Performs any necessary redirections (see Redirections) and removes the redirection operators and their operands from the argument list.
Executes the command (see Executing Commands).
Optionally waits for the command to complete and collects its exit status (see Exit Status).
So, as far as I understand, reserved words and operators are recognized as such basically at the same time (2nd step).
Q: Does the order between recognizing
time
as a reserved word and recognizing|
as a control operator determines whethertime
applies tocommand1
orcommand1 | command2
?
The Bash's time
reserved word applies to pipelines and the POSIX's time
external utility applies to simple commands, it's not a matter of recognition order.
1
As I noted in another comment, POSIX allowstime
to be a keyword.
â muru
May 18 at 6:14
1
Isn'tcommand
also POSIX? Also, in Bash, you could quote the keyword, so it won't recognize it as such:time foo
runs the external commandtime
â ilkkachu
May 18 at 6:16
@muru Yes, but my point is that POSIX does not requiretime
to be a keyword. In the same page both you and I linked says: "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 in that pipeline". And, in the "unspecified" definition: "The value or behavior may vary among implementations that conform to POSIX.1-2017. An application should not rely on the existence or validity of the value or behavior.". That's why I wrote: "In shells without atime
reserved word,time
applies tocommand1
".
â nxnev
May 18 at 6:36
@nxnev that maybe your point, but you have repeatedly said that POSIXtime
has to be external. My point is that POSIX makes no such requirement.
â muru
May 18 at 6:38
@ilkkachu 1)command
is POSIX, but IMHO using that workaround in a shell wheretime
is not a keyword but an external command is redundant; using it in Bash (and KSH, and ZSH, ...) makes more sense. 2) That's right, just added that example. Thanks!
â nxnev
May 18 at 6:38
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
time command1 | command2
Does
time
apply tocommand1
orcommand1 | command2
? If your answer is one of the two, how would you specify the other?
In Bash:
time
is a reserved word- It applies to pipelines
In POSIX:
time
is an external utility- It applies to simple commands
In Bash and other shells with a time
reserved word, time
applies to the entire pipeline (command1 | command2
). In shells without a time
reserved word, time
applies to command1
.
However, in Bash you can force time
to apply to command1
running command time command1 | command2
(this one will run the external utility if it's available), time command1; | command2
(this one is POSIX-compliant) or time command1 | command2
(or any other variant where time
is quoted, this will also run the external utility; thanks ilkkachu!).
Q: Could you explain your answer based on the grammar of bash or how the shell interprets the command?
Bash's manual explains this in the 3.2.2 Pipelines chapter:
The format for a pipeline is
[time [-p]] [!] command1 [ | or |& command2 ] â¦
The reserved word
time
causes timing statistics to be printed for the pipeline once it finishes.
And POSIX in time
's manual:
time [-p] utility [argument...]
The
time
utility shall invoke the utility named by theutility
operand with arguments supplied as theargument
operands and write a message to standard error that lists timing statistics for the utility.
Q: When the shell parses the command, does it recognize
time
as a reserved word before recognizing|
as a control operator?
Bash's manual says:
The following is a brief description of the shellâÂÂs operation when it reads and executes a command. Basically, the shell does the following:
Reads its input from a file (see Shell Scripts), from a string supplied as an argument to the
-c
invocation option (see Invoking Bash), or from the userâÂÂs terminal.
Breaks the input into words and operators, obeying the quoting rules described in Quoting. These tokens are separated by
metacharacters
. Alias expansion is performed by this step (see Aliases).
Parses the tokens into simple and compound commands (see Shell Commands).
Performs the various shell expansions (see Shell Expansions), breaking the expanded tokens into lists of filenames (see Filename Expansion) and commands and arguments.
Performs any necessary redirections (see Redirections) and removes the redirection operators and their operands from the argument list.
Executes the command (see Executing Commands).
Optionally waits for the command to complete and collects its exit status (see Exit Status).
So, as far as I understand, reserved words and operators are recognized as such basically at the same time (2nd step).
Q: Does the order between recognizing
time
as a reserved word and recognizing|
as a control operator determines whethertime
applies tocommand1
orcommand1 | command2
?
The Bash's time
reserved word applies to pipelines and the POSIX's time
external utility applies to simple commands, it's not a matter of recognition order.
time command1 | command2
Does
time
apply tocommand1
orcommand1 | command2
? If your answer is one of the two, how would you specify the other?
In Bash:
time
is a reserved word- It applies to pipelines
In POSIX:
time
is an external utility- It applies to simple commands
In Bash and other shells with a time
reserved word, time
applies to the entire pipeline (command1 | command2
). In shells without a time
reserved word, time
applies to command1
.
However, in Bash you can force time
to apply to command1
running command time command1 | command2
(this one will run the external utility if it's available), time command1; | command2
(this one is POSIX-compliant) or time command1 | command2
(or any other variant where time
is quoted, this will also run the external utility; thanks ilkkachu!).
Q: Could you explain your answer based on the grammar of bash or how the shell interprets the command?
Bash's manual explains this in the 3.2.2 Pipelines chapter:
The format for a pipeline is
[time [-p]] [!] command1 [ | or |& command2 ] â¦
The reserved word
time
causes timing statistics to be printed for the pipeline once it finishes.
And POSIX in time
's manual:
time [-p] utility [argument...]
The
time
utility shall invoke the utility named by theutility
operand with arguments supplied as theargument
operands and write a message to standard error that lists timing statistics for the utility.
Q: When the shell parses the command, does it recognize
time
as a reserved word before recognizing|
as a control operator?
Bash's manual says:
The following is a brief description of the shellâÂÂs operation when it reads and executes a command. Basically, the shell does the following:
Reads its input from a file (see Shell Scripts), from a string supplied as an argument to the
-c
invocation option (see Invoking Bash), or from the userâÂÂs terminal.
Breaks the input into words and operators, obeying the quoting rules described in Quoting. These tokens are separated by
metacharacters
. Alias expansion is performed by this step (see Aliases).
Parses the tokens into simple and compound commands (see Shell Commands).
Performs the various shell expansions (see Shell Expansions), breaking the expanded tokens into lists of filenames (see Filename Expansion) and commands and arguments.
Performs any necessary redirections (see Redirections) and removes the redirection operators and their operands from the argument list.
Executes the command (see Executing Commands).
Optionally waits for the command to complete and collects its exit status (see Exit Status).
So, as far as I understand, reserved words and operators are recognized as such basically at the same time (2nd step).
Q: Does the order between recognizing
time
as a reserved word and recognizing|
as a control operator determines whethertime
applies tocommand1
orcommand1 | command2
?
The Bash's time
reserved word applies to pipelines and the POSIX's time
external utility applies to simple commands, it's not a matter of recognition order.
edited May 18 at 6:35
answered May 18 at 5:14
nxnev
2,3471423
2,3471423
1
As I noted in another comment, POSIX allowstime
to be a keyword.
â muru
May 18 at 6:14
1
Isn'tcommand
also POSIX? Also, in Bash, you could quote the keyword, so it won't recognize it as such:time foo
runs the external commandtime
â ilkkachu
May 18 at 6:16
@muru Yes, but my point is that POSIX does not requiretime
to be a keyword. In the same page both you and I linked says: "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 in that pipeline". And, in the "unspecified" definition: "The value or behavior may vary among implementations that conform to POSIX.1-2017. An application should not rely on the existence or validity of the value or behavior.". That's why I wrote: "In shells without atime
reserved word,time
applies tocommand1
".
â nxnev
May 18 at 6:36
@nxnev that maybe your point, but you have repeatedly said that POSIXtime
has to be external. My point is that POSIX makes no such requirement.
â muru
May 18 at 6:38
@ilkkachu 1)command
is POSIX, but IMHO using that workaround in a shell wheretime
is not a keyword but an external command is redundant; using it in Bash (and KSH, and ZSH, ...) makes more sense. 2) That's right, just added that example. Thanks!
â nxnev
May 18 at 6:38
add a comment |Â
1
As I noted in another comment, POSIX allowstime
to be a keyword.
â muru
May 18 at 6:14
1
Isn'tcommand
also POSIX? Also, in Bash, you could quote the keyword, so it won't recognize it as such:time foo
runs the external commandtime
â ilkkachu
May 18 at 6:16
@muru Yes, but my point is that POSIX does not requiretime
to be a keyword. In the same page both you and I linked says: "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 in that pipeline". And, in the "unspecified" definition: "The value or behavior may vary among implementations that conform to POSIX.1-2017. An application should not rely on the existence or validity of the value or behavior.". That's why I wrote: "In shells without atime
reserved word,time
applies tocommand1
".
â nxnev
May 18 at 6:36
@nxnev that maybe your point, but you have repeatedly said that POSIXtime
has to be external. My point is that POSIX makes no such requirement.
â muru
May 18 at 6:38
@ilkkachu 1)command
is POSIX, but IMHO using that workaround in a shell wheretime
is not a keyword but an external command is redundant; using it in Bash (and KSH, and ZSH, ...) makes more sense. 2) That's right, just added that example. Thanks!
â nxnev
May 18 at 6:38
1
1
As I noted in another comment, POSIX allows
time
to be a keyword.â muru
May 18 at 6:14
As I noted in another comment, POSIX allows
time
to be a keyword.â muru
May 18 at 6:14
1
1
Isn't
command
also POSIX? Also, in Bash, you could quote the keyword, so it won't recognize it as such: time foo
runs the external command time
â ilkkachu
May 18 at 6:16
Isn't
command
also POSIX? Also, in Bash, you could quote the keyword, so it won't recognize it as such: time foo
runs the external command time
â ilkkachu
May 18 at 6:16
@muru Yes, but my point is that POSIX does not require
time
to be a keyword. In the same page both you and I linked says: "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 in that pipeline". And, in the "unspecified" definition: "The value or behavior may vary among implementations that conform to POSIX.1-2017. An application should not rely on the existence or validity of the value or behavior.". That's why I wrote: "In shells without a time
reserved word, time
applies to command1
".â nxnev
May 18 at 6:36
@muru Yes, but my point is that POSIX does not require
time
to be a keyword. In the same page both you and I linked says: "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 in that pipeline". And, in the "unspecified" definition: "The value or behavior may vary among implementations that conform to POSIX.1-2017. An application should not rely on the existence or validity of the value or behavior.". That's why I wrote: "In shells without a time
reserved word, time
applies to command1
".â nxnev
May 18 at 6:36
@nxnev that maybe your point, but you have repeatedly said that POSIX
time
has to be external. My point is that POSIX makes no such requirement.â muru
May 18 at 6:38
@nxnev that maybe your point, but you have repeatedly said that POSIX
time
has to be external. My point is that POSIX makes no such requirement.â muru
May 18 at 6:38
@ilkkachu 1)
command
is POSIX, but IMHO using that workaround in a shell where time
is not a keyword but an external command is redundant; using it in Bash (and KSH, and ZSH, ...) makes more sense. 2) That's right, just added that example. Thanks!â nxnev
May 18 at 6:38
@ilkkachu 1)
command
is POSIX, but IMHO using that workaround in a shell where time
is not a keyword but an external command is redundant; using it in Bash (and KSH, and ZSH, ...) makes more sense. 2) That's right, just added that example. Thanks!â nxnev
May 18 at 6:38
add a comment |Â
From your previous question: the accepted answer's second line is: "This is possible because the time built-in takes a pipeline as its arguments", and the third answer: "time is a shell keyword".
â muru
May 18 at 2:26
@muru That is a different question. My question here is whether
time
applies to the pipeline or just its first component.â Tim
May 18 at 3:50
1
And the part of "the time built-in takes a pipeline as its arguments" you're having trouble understanding is?
â muru
May 18 at 3:51
"Does the order determines whether
time
applies tocommand1
orcommand1 | command2
?" The "order" of what? I'm writting an answer so I'd want to know what you meant by this.â nxnev
May 18 at 4:11