Dear all, I think I found a rather interesting bug: ``` #!/bin/bash
function badCode {
echo "bad code executed"
}
function testCode {
#pick some existing file, nonexisting works too though
echo "/etc/passwd"
}
function tfunc {
local foo=
foo="$(testCode)" || {echo "foo";}
cat "$foo" || {
badCode
case $? in
*)
exit 1
esac
}
}
echo "Finished."
```
(I also attached it.)
I guess 99% of programmers would either expect "Finished" to be printed or some syntax
error. In fact however the `badCode` function is executed. "Finished" is never executed.
This is a nice one to hide bad code...
Output:
```
cat: '': No such file or directory
bad code executed
```
Affected bash versions:
Debian 11: GNU bash, version 5.1.4(1)-release (x86_64-pc-linux-gnu)
Fedora 32: GNU bash, version 5.0.17(1)-release (x86_64-redhat-linux-gnu)
(Probably more, these were the only two I tested.)
Happy bug hunting!
Best Regards
David#!/bin/bash
function badCode {
echo "bad code executed"
}
function testCode {
#pick some existing file
echo "/etc/passwd"
}
function tfunc {
local foo=
foo="$(testCode)" || {echo "foo";}
cat "$foo" || {
badCode
case $? in
*)
exit 1
esac
}
}
echo "Finished."
smime.p7s
Description: S/MIME Cryptographic Signature
