From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 28 03:59:58 2011 Received: (at submit) by debbugs.gnu.org; 28 Dec 2011 08:59:58 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RfpMc-0005S5-6V for submit@debbugs.gnu.org; Wed, 28 Dec 2011 03:59:58 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RfmnY-0001nm-KE for submit@debbugs.gnu.org; Wed, 28 Dec 2011 01:15:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rfmkv-0003PZ-5M for submit@debbugs.gnu.org; Wed, 28 Dec 2011 01:12:53 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([140.186.70.17]:59842) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rfmku-0003PS-Qf for submit@debbugs.gnu.org; Wed, 28 Dec 2011 01:12:52 -0500 Received: from eggs.gnu.org ([140.186.70.92]:41413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rfmkt-0004Zu-PU for bug-coreutils@gnu.org; Wed, 28 Dec 2011 01:12:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rfmks-0003P3-N5 for bug-coreutils@gnu.org; Wed, 28 Dec 2011 01:12:51 -0500 Received: from mail-vx0-f169.google.com ([209.85.220.169]:42751) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rfmks-0003Or-Kn for bug-coreutils@gnu.org; Wed, 28 Dec 2011 01:12:50 -0500 Received: by vcge1 with SMTP id e1so10221460vcg.0 for ; Tue, 27 Dec 2011 22:12:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=yh3D8BkLWHMmKfhlzR+/iY/WDFUA/y1nxo8j85N5os4=; b=TzuGGgH5CT3LoRdzsuC7ymG8u7Jkxki8PEFpbT5f4aHioTkL7jrRz1VD9pG2gAiIZw k1wAC0V3Qvhjj+xGNKyzpvilC9McjvNrYcexurgMEuKA5KEanaJQilPbD4ZNkoVAi0c3 BVnkNgSUqqprEfYPO9habXniKvU5Z5zrBfwuc= MIME-Version: 1.0 Received: by 10.52.89.34 with SMTP id bl2mr14597601vdb.116.1325052769607; Tue, 27 Dec 2011 22:12:49 -0800 (PST) Received: by 10.220.181.71 with HTTP; Tue, 27 Dec 2011 22:12:49 -0800 (PST) Date: Wed, 28 Dec 2011 00:12:49 -0600 Message-ID: Subject: Bug with Test Command From: "Mathi.C" To: bug-coreutils@gnu.org Content-Type: multipart/alternative; boundary=20cf307cfce6a41ee404b520e3c9 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Wed, 28 Dec 2011 03:59:55 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) --20cf307cfce6a41ee404b520e3c9 Content-Type: text/plain; charset=ISO-8859-1 Hi, I have come across a scenario where test command resulted wrong result than expected. Please follow the below steps to simulate the scenario. 1. Define a variable to blank/null export a= 2. Test the parameter with test command on file exists test -f $a 3. Echo the result of the last executed command echo $? Result we get is "0" -success, whereas the test command (step 2) should error with parameter expected after " test -f". -- Regards, Mathi.C --20cf307cfce6a41ee404b520e3c9 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi,

I have come across a scenario where test command res= ulted wrong result than expected.

Please follow th= e below steps to simulate the scenario.
1. Define a variable to b= lank/null
=A0 =A0 =A0export a=3D
2. Test the parameter with test comma= nd on file exists
=A0 =A0 =A0test -f $a
3. Echo the res= ult of the last executed command=A0
=A0 =A0 echo $?
Result we get is "0" -success, whereas the test comma= nd (step 2) should error with parameter expected after " test -f"= .

--
Regards,
Mathi.C
--20cf307cfce6a41ee404b520e3c9-- From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 28 08:31:01 2011 Received: (at control) by debbugs.gnu.org; 28 Dec 2011 13:31:01 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rftar-0005Uy-L6 for submit@debbugs.gnu.org; Wed, 28 Dec 2011 08:31:01 -0500 Received: from mx1.redhat.com ([209.132.183.28]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rftam-0005Ud-EJ; Wed, 28 Dec 2011 08:30:54 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id pBSDS71D014946 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 28 Dec 2011 08:28:07 -0500 Received: from [10.3.113.42] (ovpn-113-42.phx2.redhat.com [10.3.113.42]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id pBSDS6e4004401; Wed, 28 Dec 2011 08:28:06 -0500 Message-ID: <4EFB1966.40702@redhat.com> Date: Wed, 28 Dec 2011 06:28:06 -0700 From: Eric Blake Organization: Red Hat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: "Mathi.C" Subject: Re: bug#10390: Bug with Test Command References: In-Reply-To: X-Enigmail-Version: 1.3.4 OpenPGP: url=http://people.redhat.com/eblake/eblake.gpg Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigFFA629E9A28130E90F62A32B" X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Spam-Score: -10.3 (----------) X-Debbugs-Envelope-To: control Cc: 10390-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -10.3 (----------) This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigFFA629E9A28130E90F62A32B Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable tag 10390 notabug thanks On 12/27/2011 11:12 PM, Mathi.C wrote: > Hi, >=20 > I have come across a scenario where test command resulted wrong result = than > expected. >=20 > Please follow the below steps to simulate the scenario. > 1. Define a variable to blank/null > export a=3D > 2. Test the parameter with test command on file exists > test -f $a There's your problem. You failed to properly quote things. Per shell expansion rules, unquoted $a is elided, rather than an empty argument, which means you passed test exactly one argument ("-f"), and since that one argument is not empty, it is always true. If you want to cope with an explicit empty string, you must use quoting: test -f "$a" > 3. Echo the result of the last executed command > echo $? As this behavior matches POSIX requirements on test, there is nothing to fix here. Also, be aware that you were probably testing your shell's built-in test, rather than coreutils' test (running the latter usually requires that you do things like 'env test' or '/usr/bin/test' to bypass shell built-ins). --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigFFA629E9A28130E90F62A32B Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJO+xlmAAoJEKeha0olJ0NqtZMH/jfSvXems+faD59r1Hx61HlZ Zkr/+jM6dO+vuHJrAKvRL1we5zxTLLQtLWPfTQzjfbxxpcIV0cBK7F8y/KExtz02 +mZuFtAK9a1NK2BI/7hAN0Xz+1sfTmC2Gd4qU7OXcqT1CygCraI8lNsA9NfqQh+M BYhQ9Uwy7d6wcmMNBJIkR3x8vDpCxeSQPtH7pgl39WfgMOTyFdl0Ogt5AOPCsq5H q6BkiovLYKCW6dYDswmltBaDuA2XfIobO/dOaP0bGabkEI8GqLNeSHIfS+lCi40J YJgvpZr6svtzIrrqE9pv9Qjv32F2PhZLZuHhFNJJ//mpK6I57EN+IlA6x2skl54= =w9HS -----END PGP SIGNATURE----- --------------enigFFA629E9A28130E90F62A32B-- From unknown Mon Aug 11 18:18:49 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 26 Jan 2012 12:24:02 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator