| 1 | #!/bin/bash |
| 2 | |
| 3 | ### Lazy Evaluation of Alternative |
| 4 | i=0 |
| 5 | x=x |
| 6 | echo ${x:-$((i++))} |
| 7 | echo $i |
| 8 | echo ${undefined:-$((i++))} |
| 9 | echo $i # i is one because the alternative was only evaluated once |
| 10 | # status: 0 |
| 11 | # stdout-json: "x\n0\n0\n1\n" |
| 12 | # N-I dash status: 2 |
| 13 | # N-I dash stdout-json: "x\n0\n" |