From nobody@FreeBSD.org  Sun Aug 28 20:08:01 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 8DDFF1065670
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 28 Aug 2011 20:08:01 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 64B7B8FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 28 Aug 2011 20:08:01 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p7SK81Lc008095
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 28 Aug 2011 20:08:01 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p7SK81YJ008094;
	Sun, 28 Aug 2011 20:08:01 GMT
	(envelope-from nobody)
Message-Id: <201108282008.p7SK81YJ008094@red.freebsd.org>
Date: Sun, 28 Aug 2011 20:08:01 GMT
From: Alexander Verbod <AN47HDTEMVQLKX3.NJKM2YX7YWVLP2@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: SHELL/BASH bug: testing condition for [ -x file ] is wrong
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         160263
>Category:       ports
>Synopsis:       shells/bash bug: testing condition for [ -x file ] is wrong
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    ehaupt
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 28 20:10:10 UTC 2011
>Closed-Date:    Sun Mar 30 11:58:41 CEST 2014
>Last-Modified:  Sun Mar 30 11:58:41 CEST 2014
>Originator:     Alexander Verbod
>Release:        8.2 release
>Organization:
>Environment:
FreeBSD dev.local 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Fri Feb 18 02:24:46 UTC 2011     root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386

Also tested under:

FreeBSD devel.loc 7.4-RELEASE FreeBSD 7.4-RELEASE #0: Thu Feb 17 03:51:56 UTC 2011     root@walker.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
Conditional expression like:

if [[ -x '/path/file' ]]; then 
or 
if [ -x '/path/file' ]; then

does not work as expected and report on file with permission set to 444 as executable.

The same conditions test under Linux(Ubuntu)works as expected.

>How-To-Repeat:
Run following script:



#! /usr/local/bin/bash
echo '======================= <BASH_bug_test> ================================';

Test_DIR=".";
Test_file="${Test_DIR}/TestFile";

/bin/echo 'Test File' >"${Test_file}";

# Set READ ONLY permissions on test file
/bin/chmod 444 "${Test_file}";


if [[ -x "${Test_file}" ]]; then        #---- bash's bug on FreeBSD

    /bin/echo "After: /bin/chmod 444 '${Test_file}' operation";
    /bin/echo "BASH think that file '${Test_file}' is EXECUTABLE,";
    /bin/echo 'on statement like: "if [[ -x "${Test_file}" ]]; then ...", but...';
    /bin/echo "/bin/ls think differently:"; /bin/echo;
    /bin/ls -laoF "${Test_file}"; /bin/echo;

    if /bin/test ! -x "${Test_file}"; then
        /bin/echo '/bin/test agree with /bin/ls too that';
        /bin/echo "'${Test_file}' is not executable"; /bin/echo;
    fi

    if [ -x "${Test_file}" ]; then        # [ aka test is not smarter eather
        /bin/echo;
        /bin/echo "BTW, BASH's"' internal "[" aka "test"';
        /bin/echo '    if [ -x "${Test_file}" ]; then ...';
        /bin/echo 'is not smarter eather :(';
    else
        /bin/echo 'Construction like: "if [ -x "${Test_file}" ]; then ..." is work.';
    fi
else
    /bin/echo "File '${Test_file}' is NOT executable";
fi

/bin/rm -f "${Test_file}"       # Be nice, clean up own poop

echo '======================= </BASH_bug_test> ===============================';
exit 0

>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->obrien 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Aug 28 20:20:50 UTC 2011 
Responsible-Changed-Why:  
Fix synopsis and assign. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=160263 

From: Alexander Verbod <an47hdtemvqlkx3.njkm2yx7ywvlp2@gmail.com>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/160263: shells/bash bug: testing condition for [ -x file ]
 is wrong
Date: Sun, 22 Apr 2012 12:43:48 -0400

 --f46d044794ddcae1e404be473901
 Content-Type: text/plain; charset=UTF-8
 
 Update:
 
 After BASH was upgraded to version 4.2.20 this bug disappeared under
 FreeBSD 7.4-RELEASE, but still continue present on
 FreeBSD-8.3-RELEASE.
 (FreeBSD-9.0 wasn't tested)
 
 New simplified test version of bug test attached.
 
 --f46d044794ddcae1e404be473901
 Content-Type: text/plain; charset=US-ASCII; name="BASH-bug-test2.txt"
 Content-Disposition: attachment; filename="BASH-bug-test2.txt"
 Content-Transfer-Encoding: base64
 X-Attachment-Id: f_h1cbra180
 
 IyEgL3Vzci9sb2NhbC9iaW4vYmFzaAovYmluL2VjaG8gJz09PT09PT09PT09PT09PT09PT09PT09
 IDxCQVNIX2J1Z190ZXN0Mj4gPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0nOwoKVGVz
 dF9ESVI9Ii4iOwpUZXN0X2ZpbGU9IiR7VGVzdF9ESVJ9L1Rlc3RGaWxlIjsKCi9iaW4vZWNobyAn
 VGVzdCBGaWxlJyA+IiR7VGVzdF9maWxlfSI7CgojIFNldCBSRUFEIE9OTFkgcGVybWlzc2lvbnMg
 b24gdGVzdCBmaWxlCi9iaW4vY2htb2QgNDQ0ICIke1Rlc3RfZmlsZX0iOwoKIyBTaG93IHJlYWwg
 ZmlsZSdzIHBlcm1pc3Npb25zCi9iaW4vbHMgLWxhb0YgIiR7VGVzdF9maWxlfSI7CgovYmluL2Vj
 aG8gJy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
 LS0tLS0tLS0tLS0tLS0tLS0tLS0nOwoKCmlmIFtbIC14ICIke1Rlc3RfZmlsZX0iIF1dOyB0aGVu
 CiAgICAvYmluL2VjaG8gIkJBU0ggZG9lc24ndCB3b3JrIGNvcnJlY3RseSEiOwogICAgL2Jpbi9l
 Y2hvICJJdCByZWNvZ25pemUgJyR7VGVzdF9maWxlfScgYXMgZXhlY3V0YWJsZS4iOwplbHNlCiAg
 ICAvYmluL2VjaG8gIkJBU0ggd29ya3MgY29ycmVjdGx5IC0gbm8gYnVnLiI7CmZpCgoKL2Jpbi9y
 bSAtZiAiJHtUZXN0X2ZpbGV9IiAjIFJlbW92ZSB0ZXN0IGZpbGUKCi9iaW4vZWNobyAnPT09PT09
 PT09PT09PT09PT09PT09PT0gPC9CQVNIX2J1Z190ZXN0Mj4gPT09PT09PT09PT09PT09PT09PT09
 PT09PT09PT09PSc7CmV4aXQgMAo=
 --f46d044794ddcae1e404be473901--
State-Changed-From-To: open->feedback 
State-Changed-By: obrien 
State-Changed-When: Thu May 31 23:09:48 UTC 2012 
State-Changed-Why:  
I don't see how this is specific to the FreeBSD port of bash 
(i.e., /usr/ports/shell/bash) vs. some bad assumption of Bash 
on libc's behavior, etc... 

Please track down to something more specific in FreeBSD or please 
report this bug using /usr/local/bin/bashbug. 

thanks. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=160263 
Responsible-Changed-From-To: obrien->ehaupt 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Mar 29 05:08:29 UTC 2014 
Responsible-Changed-Why:  
Over to new maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=160263 
State-Changed-From-To: feedback->closed 
State-Changed-By: ehaupt 
State-Changed-When: Sun Mar 30 11:58:30 CEST 2014 
State-Changed-Why:  
Bug should be reported upstream. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=160263 
>Unformatted:
