Are the following two command lists portably equivalent?
$foo; echo $? #(1)
$foo && echo 0 || echo $? #(2)
Consider the command
exit-status defined so:
#!/bin/sh exit "$1"
Does the POSIX standard forbid the following?
> exit-status 2 && echo "impossible branch"; echo $? 1
If not, then a POSIX-compliant shell could fail to equate the two uppermost command lists. Which isn't quite the same thing as not being portable...