Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 2
    This will run C2 if C1 fails, which violates the specification laid out in the question (namely, that only one of the commands is run). x && y || z is not equivalent to if x; then y; else z; fi. Commented Jul 3, 2013 at 4:34
  • @ChrisDown - see mods. Commented Jul 3, 2013 at 4:48
  • 4
    The edit nominally fixes this, but it's really obscure. "If you're concerned with C1 having to fail so that C2 can run" doesn't capture the scenario at all. The issue is that if C1 is a command which sometimes returns a non-zero exit code, you will end up executing both C1 and C2 when that happens. Commented Jul 3, 2013 at 6:23
  • +1 but use ((...)) instead of [...] -- double parentheses are specifically for arithmetic expressions. Commented Jul 3, 2013 at 9:45
  • One more simplification: you don't need $(()) inside (()) -- (( RANDOM%2 == 0 )) Commented Jul 3, 2013 at 11:59