[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Unexpected space in conditional taints subsequent conditional

From: Todd Stein
Subject: Unexpected space in conditional taints subsequent conditional
Date: Tue, 18 Oct 2022 21:31:35 -0700

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -O2 -flto=auto -ffat-lto-objects -fexceptions -g
-grecord-gcc-switches -pipe -Wall -Werror=format-security
-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong
-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64  -mtune=generic
-fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection
uname output: Linux tibsora.home.arpa 5.19.14-200.fc36.x86_64 #1 SMP
PREEMPT_DYNAMIC Wed Oct 5 21:31:17 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-redhat-linux-gnu

Bash Version: 5.2
Patch Level: 2
Release Status: release

Including an erroneous space in a double-bracket conditional results in an
error, as it should, but it also taints the next conditional that gets
interpreted, forcing an an exit status of 2 regardless of syntax. This
taint persists through non-conditional commands.

Here's an example of the issue. Note that the first echo (in the third
command) does not execute -- the entire line seems to be eaten.

$ [[ a b ]]
bash: conditional binary operator expected
$ date
Tue Oct 18 09:17:20 PM PDT 2022
$ [[ a ]]; echo $?
bash: syntax error near unexpected token `a'
$ echo $?
$ [[ a ]]; echo $?

This also happens with other types of conditional expressions. Note that
the initial error is different in this example but the taint still occurs.

$ [[ "a b" =~ a b ]] && echo "match"
bash: syntax error in conditional expression
$ [[ $((1+1)) == 2 ]] && echo "Yay, MATH"
bash: syntax error near unexpected token `$((1+1))'
$ [[ $((1+1)) == 2 ]] && echo "Yay, MATH"

This does not happen in bash 3.2.57 or zsh 5.8.

Best regards,

Best regards,

reply via email to

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