[Top][All Lists]

[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" || {
         case $? in
            exit 1

The bug is in your code.

https://shellcheck.net/ static analysis for shell scripts can help you spot such syntax errors.

Léa Gris

reply via email to

[Prev in Thread] Current Thread [Next in Thread]