On 2/12/22 17:52, Brendan Hoar wrote:
  On Sat, Feb 12, 2022 at 11:31 AM HW42 <[email protected]> wrote:

So this is probably not even a bug. Thanks for the nice example David
(apropos shell: set -e semantics are also "fun").

Simon


I’m going to guess (again, away from Linux terminal right now) that the
shellcheck command would probably flag this…

That's true unless you do something more obvious such as
```
#!/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."
```

…and that’s part of why the Qubes CI pipeline utilizes shellcheck.

Definitely a good thing.

Btw I now believe that the {echo in the original example is considered a string 
and the second } closes the function. I just don't understand why the case/esac 
can be used to remove the syntax error caused by the double } }. But oh well...

--
You received this message because you are subscribed to the Google Groups 
"qubes-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-devel/6ba7e4d4-f300-c160-0970-a34932d6cbb5%40hackingthe.net.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to