Numeric test when using the conditional operator
- by lupuslupus
In bash, why doesn't this work:
$ echo $((1 -gt 2 ? 3 : 4))
bash: 1 -gt 2 ? 3 : 4: syntax error in expression (error token is "2 ? 3 : 4")
Neither does this:
$ echo $(((1 -gt 2) ? 3 : 4))
bash: (1 -gt 2) ? 3 : 4: missing `)' (error token is "2) ? 3 : 4")