bug-bash
[Top][All Lists]
Advanced

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

Improper handling of \! and \( while using Bash V4.1.2


From: anant garg
Subject: Improper handling of \! and \( while using Bash V4.1.2
Date: Mon, 6 Aug 2018 16:14:49 +0530

Hi ,

I am using the below environment.

Linux kernel :- kernel-2.6.32-504.16.2.el6.x86_64
Bash version :- bash-4.1.2-29.x86_64

In our production code, one test related to parameter validation failed as
below :-

$ mode=!
$ [ "$mode" != "ro" -a "$mode" != "rw" ] && echo OK
+ '[' '!' '!=' ro -a '!' '!=' rw ']'
bash: [: too many arguments

I checked the source and found that when multiple checks are done in one
single test expression then ! parsing fails.

For eg, the below works :-
$ mode=!
$ [ "$mode" != "ro" ] && echo OK
OK

The below also works :-
$ mode=\!
$ [ "$mode" != "ro" ] && echo OK
OK


The below also works :-
$ mode=\(
$ [ "$mode" != "ro" ] && echo OK
OK


but when below is run where multiple conditions are tested, then the
parsing fails.

For eg:-
mode=\(
[ "$mode" != "ro" -a "$mode" != "rw" ] && echo OK
bash: [: `)' expected, found ro

I tried testing with other special characters as well, but this issue came
with only !,\! or \(.

When I tested with extended test i.e [[ , this issue did not came.
Was there any known bug in Bash V4.1.2 related to parsing of multiple ! or
\( in [.


reply via email to

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