and_or_and_backgrounding.tests 1002 B

123456789101112131415161718192021222324252627282930
  1. # According to this doc, && || have higher precedence than ; &.
  2. # See example below.
  3. # Precedence of ; is not a problem in practice. Precedence of & is.
  4. #
  5. #http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
  6. #
  7. #2.9.3 Lists
  8. #
  9. #An AND-OR list is a sequence of one or more pipelines separated by
  10. #the operators "&&" and "||" .
  11. #
  12. #A list is a sequence of one or more AND-OR lists separated by the operators
  13. #';' and '&' and optionally terminated by ';', '&', or <newline>.
  14. #
  15. #The operators "&&" and "||" shall have equal precedence and shall be
  16. #evaluated with left associativity. For example, both of the following
  17. #commands write solely bar to standard output:
  18. #
  19. # false && echo foo || echo bar
  20. # true || echo foo && echo bar
  21. #
  22. #A ';' or <newline> terminator shall cause the preceding AND-OR list
  23. #to be executed sequentially; an '&' shall cause asynchronous execution
  24. #of the preceding AND-OR list.
  25. echo First && sleep 0.2 && echo Third &
  26. sleep 0.1
  27. echo Second
  28. wait
  29. echo Done