On 2/12/22 1:24 PM, David Hobach wrote:
I guess 99% of programmers would either expect "Finished" to be printed
or some syntax error.
Well, 99% of shell programmers will (hopefully ;-) ) put a blank between
"{" and "echo" in the line
foo="$(testCode)" || {echo "foo";}
Yes, the interesting part is that depending on which space you accidentally
forget, you'll either get the expected "Finished" or "bad code executed".
foo="$(testCode)" || {echo "foo"; } # --> bad code
foo="$(testCode)" || { echo "foo";} # --> Finished
I guess it closes the function and {echo is interpreted as string or so,
but that is probably not all (testCode is e.g. never executed).
It's not executed because it's part of a function that's never called.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/