mainThe GNU Bourne-Again SHell - Support: sr #110745, Unexpected space in conditional...

 
 

sr #110745: Unexpected space in conditional taints subsequent conditional

Submitter:  None
Submitted:  Wed 19 Oct 2022 07:54:28 PM UTC
   
 
Category:  None Priority:  5 - Normal
Severity:  3 - Normal Status:  Done
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  GNU/Linux
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 20 Oct 2022 05:02:51 PM UTC, comment #1: 

Thanks for the report. It's not the space, but the syntax error
(`b' is not a valid binary operator). The parser error recovery
token doesn't result in the parser state being reset correctly.

It's an interactive-only issue. It will be fixed in the next  devel branch push.

Chet

Chet Ramey <chet>
Group administrator
Wed 19 Oct 2022 07:54:28 PM UTC, original submission:  

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

Description:
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.

Repeat-By:
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 $?
2
$ [[ a ]]; echo $?
0


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"
Yay, MATH


This does not happen in bash 3.2.57 or zsh 5.8.

Best regards,
Todd

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by chet (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-10-20 chet StatusNone Done

    Back to the top

    Powered by Savane 3.13-12ab.
    Corresponding source code