How can we make `time` apply to a pipeline or its component? [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash 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.







share|improve this 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 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 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















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.







share|improve this 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 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 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













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.







share|improve this question














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









share|improve this question












share|improve this question




share|improve this question








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 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 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

















  • 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 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
















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











1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted











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?




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 the utility operand with arguments supplied as the argument 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:



  1. 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.


  2. 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).


  3. Parses the tokens into simple and compound commands (see Shell Commands).


  4. Performs the various shell expansions (see Shell Expansions), breaking the expanded tokens into lists of filenames (see Filename Expansion) and commands and arguments.


  5. Performs any necessary redirections (see Redirections) and removes the redirection operators and their operands from the argument list.


  6. Executes the command (see Executing Commands).


  7. 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 whether time applies to command1 or command1 | 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.






share|improve this answer



















  • 1




    As I noted in another comment, POSIX allows time to be a keyword.
    – muru
    May 18 at 6:14






  • 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










  • @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











  • @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

















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 to command1 or command1 | 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 the utility operand with arguments supplied as the argument 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:



  1. 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.


  2. 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).


  3. Parses the tokens into simple and compound commands (see Shell Commands).


  4. Performs the various shell expansions (see Shell Expansions), breaking the expanded tokens into lists of filenames (see Filename Expansion) and commands and arguments.


  5. Performs any necessary redirections (see Redirections) and removes the redirection operators and their operands from the argument list.


  6. Executes the command (see Executing Commands).


  7. 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 whether time applies to command1 or command1 | 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.






share|improve this answer



















  • 1




    As I noted in another comment, POSIX allows time to be a keyword.
    – muru
    May 18 at 6:14






  • 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










  • @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











  • @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














up vote
3
down vote



accepted











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?




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 the utility operand with arguments supplied as the argument 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:



  1. 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.


  2. 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).


  3. Parses the tokens into simple and compound commands (see Shell Commands).


  4. Performs the various shell expansions (see Shell Expansions), breaking the expanded tokens into lists of filenames (see Filename Expansion) and commands and arguments.


  5. Performs any necessary redirections (see Redirections) and removes the redirection operators and their operands from the argument list.


  6. Executes the command (see Executing Commands).


  7. 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 whether time applies to command1 or command1 | 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.






share|improve this answer



















  • 1




    As I noted in another comment, POSIX allows time to be a keyword.
    – muru
    May 18 at 6:14






  • 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










  • @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











  • @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












up vote
3
down vote



accepted







up vote
3
down vote



accepted







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?




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 the utility operand with arguments supplied as the argument 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:



  1. 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.


  2. 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).


  3. Parses the tokens into simple and compound commands (see Shell Commands).


  4. Performs the various shell expansions (see Shell Expansions), breaking the expanded tokens into lists of filenames (see Filename Expansion) and commands and arguments.


  5. Performs any necessary redirections (see Redirections) and removes the redirection operators and their operands from the argument list.


  6. Executes the command (see Executing Commands).


  7. 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 whether time applies to command1 or command1 | 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.






share|improve this answer
















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?




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 the utility operand with arguments supplied as the argument 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:



  1. 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.


  2. 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).


  3. Parses the tokens into simple and compound commands (see Shell Commands).


  4. Performs the various shell expansions (see Shell Expansions), breaking the expanded tokens into lists of filenames (see Filename Expansion) and commands and arguments.


  5. Performs any necessary redirections (see Redirections) and removes the redirection operators and their operands from the argument list.


  6. Executes the command (see Executing Commands).


  7. 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 whether time applies to command1 or command1 | 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.







share|improve this answer















share|improve this answer



share|improve this answer








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 allows time to be a keyword.
    – muru
    May 18 at 6:14






  • 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










  • @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











  • @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












  • 1




    As I noted in another comment, POSIX allows time to be a keyword.
    – muru
    May 18 at 6:14






  • 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










  • @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











  • @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







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


Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?