helpThe GNU Bourne-Again SHell - Support: sr #108555, builtin test misinterprets "(...


sr #108555: builtin test misinterprets "( ! ! )" expression

Submitted by:  None
Submitted on:  Tue 22 Apr 2014 01:26:55 PM UTC  
Category: NonePriority: 5 - Normal
Severity: 3 - NormalStatus: Invalid
Privacy: PublicAssigned to: None
Originator Email: -unavailable-Open/Closed: Open
Operating System: GNU/Linux

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Wed 04 Jun 2014 06:32:51 AM UTC, comment #1:

Not a bug.

! alone is not enough for a test and what test does really depends on the number of its arguments.

So your test is really:

test \( ! ! string

with string = )

and bash correctly reports you are missing a closing paren.

Tue 22 Apr 2014 01:26:55 PM UTC, original submission:

[miky@gremlin ~]$ bash -version
GNU bash, version 4.3.8(1)-release (x86_64-unknown-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[miky@gremlin ~]$ builtin test \( ! ! \)
bash: test: `)' expected
[miky@gremlin ~]$ echo $?
[miky@gremlin ~]$

The bug is in term() function in test.c: the argv[pos] is not tested for ")" in top-level but only in the if ( "(" ) {} branch. The last top-level test "consumes" the last argument before it returns back to the original call origin within the if ( "(" ) {} branch.

Not a C developer, hence no patch. Sorry.



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

Attach File(s):

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by chet (Updated the item)
  • -unavailable- added by None (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follows 1 latest change.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 13 Nov 2015 02:51:25 AM UTCchetStatusNone=>Invalid

    Back to the top

    Powered by Savane 3.1-cleanup