On Wed, Sep 10, 2025 at 01:50:55PM -0700, Martin Jambon wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS: -g -O2 -fno-omit-frame-pointer
> -mno-omit-leaf-frame-pointer>
> uname output: Linux mj1 6.14.0-24-generic #24~24.04.3-Ubuntu SMP
> PREEMPT_DYNAMI>
> Machine Type: x86_64-pc-linux-gnu
>
> Bash Version: 5.2
> Patch Level: 21
> Release Status: release
>
> Description:
>
>    I wrote a script in which I accidentally omitted a semicolon after a
>    ]] and before a then. It didn't work for a colleague of mine using
>    another version of Bash.
>
>    Expectation: I expect a syntax error in the absence of a semicolon
>    or a newline between the closing brackets and the then.
>
>    Behavior with Bash 5.2.21: no error, the program behaves as if a
>    semicolon was present.
>
> Repeat-By:
>
>    Run the following snippet:
>
>    if [[ -z "" ]] then
>       echo hello
>    fi
>
>    Expected behavior: syntax error
>
>    Actual behavior: prints "hello"
>
> Fix: (none provided)

I pasted the above 3 commands into another window and did get an error:

$    if [[ -z "" ]] then
>       echo hello
>    fi
-bash:  : command not found

The error occurs because the 2nd-last space before the echo command is U+00A0
(NO-BREAK SPACE (NBSP)). My editor [1] shows this in the error message above:-

-bash: ^<302>^<240>: command not found

Bash is not recognising U+00A0 as whitespace. What to do about it, if anything?

Cheers ... Duncan.

[1] https://github.com/duncan-roe/q/

Reply via email to