[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Interesting bug
From: |
Léa Gris |
Subject: |
Re: Interesting bug |
Date: |
Sat, 12 Feb 2022 16:42:16 +0100 |
User-agent: |
Telnet/1.0 [tlh] (PDP11/DEC) |
On 12/02/2022 at 12:23, David Hobach wrote:
function tfunc {
local foo=
foo="$(testCode)" || {echo "foo";}
^ Missing space after opening brace
Because the code block is missing a space after the opening brace; the
opening brace is ignored, but the following closing brace is parsed as
the end for the tfunc function code block.
The following statements are executed for the global scope since the
function definition block is closed by the faulty syntax above.
cat "$foo" || {
badCode
case $? in
*)
exit 1
esac
}
}
The bug is in your code.
https://shellcheck.net/ static analysis for shell scripts can help you
spot such syntax errors.
--
Léa Gris
- Interesting bug, David Hobach, 2022/02/12
- Re: Interesting bug, Martin Schulte, 2022/02/12
- Re: Interesting bug, David Hobach, 2022/02/12
- Re: Interesting bug, David Hobach, 2022/02/12
- Re: Interesting bug, Andreas Schwab, 2022/02/12
- Re: Interesting bug, Martin Schulte, 2022/02/12
- Re: Interesting bug, Ilkka Virta, 2022/02/12
- Re: Interesting bug, David Hobach, 2022/02/12
- Re: Interesting bug, Chet Ramey, 2022/02/13
- Re: Interesting bug, Chet Ramey, 2022/02/13
Re: Interesting bug,
Léa Gris <=