From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 19 16:59:12 2018 Received: (at submit) by debbugs.gnu.org; 19 Oct 2018 20:59:12 +0000 Received: from localhost ([127.0.0.1]:59830 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gDbrT-0003il-RO for submit@debbugs.gnu.org; Fri, 19 Oct 2018 16:59:12 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48365) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gDbha-0003U4-53 for submit@debbugs.gnu.org; Fri, 19 Oct 2018 16:48:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDbhU-0006xc-9q for submit@debbugs.gnu.org; Fri, 19 Oct 2018 16:48:52 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:60556) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gDbhR-0006so-Nc for submit@debbugs.gnu.org; Fri, 19 Oct 2018 16:48:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57955) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDbhR-0006yt-00 for bug-coreutils@gnu.org; Fri, 19 Oct 2018 16:48:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gDbhL-0006ZX-Kp for bug-coreutils@gnu.org; Fri, 19 Oct 2018 16:48:48 -0400 Received: from s5.ds-gmbh.de ([91.184.37.130]:47275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gDbhK-0006Cw-RK for bug-coreutils@gnu.org; Fri, 19 Oct 2018 16:48:43 -0400 Received: from martnix4 (aftr-37-201-194-48.unity-media.net [37.201.194.48]) by s5.ds-gmbh.de (Postfix) with ESMTPA id 0DF041D4105 for ; Fri, 19 Oct 2018 22:49:24 +0200 (CEST) Date: Fri, 19 Oct 2018 22:48:22 +0200 From: Martin Schulte To: bug-coreutils@gnu.org Subject: test has filetest -a but man page doesn't list it Message-Id: <20181019224822.7994ce73bb7009249d7d2a14@schrader-schulte.de> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Fri, 19 Oct 2018 16:59:10 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Hello coreutils maintainers, test in coreutils 8.30 supports the unary -a test (is the same as -e) but this is not listed on the manpage (in bash 4.4.12 "help test" does list it). I can imagine good reasons to kick out the unary -a but I think it then should be kicked out of program and man page (or it should be listed in the man page, maybe as deprecated). Best regards, Martin From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 19 18:56:10 2018 Received: (at 33097) by debbugs.gnu.org; 19 Oct 2018 22:56:10 +0000 Received: from localhost ([127.0.0.1]:59965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gDdgg-0002GJ-Bk for submit@debbugs.gnu.org; Fri, 19 Oct 2018 18:56:10 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:49049) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gDdge-0002G7-PO for 33097@debbugs.gnu.org; Fri, 19 Oct 2018 18:56:09 -0400 Received: from [192.168.101.10] ([91.12.166.119]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MwQw1-1fOI3L32eb-00sQtD; Sat, 20 Oct 2018 00:56:02 +0200 Received: from [192.168.101.10] ([91.12.166.119]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MwQw1-1fOI3L32eb-00sQtD; Sat, 20 Oct 2018 00:56:02 +0200 Subject: Re: bug#33097: test has filetest -a but man page doesn't list it To: Martin Schulte , 33097@debbugs.gnu.org References: <20181019224822.7994ce73bb7009249d7d2a14@schrader-schulte.de> From: Bernhard Voelker Openpgp: preference=signencrypt Autocrypt: addr=mail@bernhard-voelker.de; prefer-encrypt=mutual; keydata= xsBNBFPirzMBCACyzYldTjQ4ufFOkByY5Nn5USb5GFoL48nWBwNHjd9KUbtRRNlQiPNKd6hK Gvd3BGi5aoFKA4ytfRk6jbAbW3jVb3R8wYaV08mOy4KVEKxqN4bxsXlMjNChXVR+rtKDmfI+ oPTL+cPH2X6gW4W02IRbVw0uUhNm6zEedC/gNrY/mTlf1enZ46jxZ7BTUZaG+kx38UMISIMB zSzLRtdkwgmHj4jS3p1fF2cwRqLclIfMjKGpbNFPEXeXKWrCLcqHw78795eAR9q0YvrDkfIn GdDBwfb3VM4NdulwIFzvYZMSXvSbbyPLB5YkHU5aAWQHUse4WlfT5ccDpbzUYldRAvF9ABEB AAHNK0Jlcm5oYXJkIFZvZWxrZXIgPG1haWxAYmVybmhhcmQtdm9lbGtlci5kZT7CwHkEEwEC ACMFAlPirzMCGwMHCwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIXgAAKCRBGUC73lpFxle5wCACC dbs0QaJ0vR3Sff2cKdTk41rUq3YfWngsR///IOU0C5DdkePmCnJE/lUsUy0LRTxcUDLxQR+x QHU8ssRT0JUO9726dI3miy36UdsgmBYaOtLvQcidGmW1R7o0PYYf04+TFtyqKgngOUBPpMgR 6o4UsQxy/OD4bN1WDqOgIjL+D/qJpkKmgp6L6+hhaBCpiOFKRmmV7YyQ3SqVlfQNiHs5ZtkR nXpIjgZARV+GllKucI17bO0CGmTJZ1tstVy0+W3DQT1lbBkTTc++5LONM99D3jjn23l1ocOp folR53F7I4cb2RNfT23v1I59RH37lB9wMOqrKj0UjYAC2YoPGQ3BzsBNBFPirzMBCADXLWWp QihBldY6reca8ZKdc3T9qXEOa3akE3DWKztIBmNJhtYOjmpLYajQTkGa7UoJTnbmZE2Rn6ZE oNnvb0gcFNAIcY95KOI+bjOR8HEgh4cx2REXh6L6olIgyXqt/KFusE4wtVZAFxZl+30HzN6n D+1HvrjXxPJRX6MsIYOYyyX9/6OofwJK6QHODYGp8WL2olHDnmsXg4AT6Wlr7qKpKrQELlcF R4xkvdmgL/Ghw/tK0yJTxMIcewCCZWLPOXRmFRbvAadZWPAgVsJ63siNyUlVnVMSzDgTJl+s l/DMabXpqrJQx3/1Yy6mTaDs3XZT/wmBKaTLXx/LByaPxQQ7ABEBAAHCwF8EGAECAAkFAlPi rzMCGwwACgkQRlAu95aRcZWVPwgAqZT6iTXkoP37wYb41323RzhBcJ8JSk4cyBDBUXX0lMrM 3qhiClKG7phpxVdu817Gwc6Hsecg7FfjQAV8MHQ0ZFeEFdk3b2rKBqfsStc+h49/xF3Fb+if CzR9qeQF82fMSxkg18++7hMcHCMO/hPZ/Q0xRi+lrSr2QKDJQuLzSyVU14TxrCkevZjEhtma VNvcJlJzCbiBXee9Fpc5jITUXPFG8E8dxqo1n+duOyIMgozrAnzP7X5V/Ob/Ozf/aGGX9+Jd inyfCX18nWcHALKMU/36Eua/ylalf/2c2YkBp9KCLVmGgPkUgW52EeRPgroIsiwu+rwCSV6Z UyCJ+OymCg== Message-ID: <6153c275-fc83-35bb-bbff-377d75ba3b57@bernhard-voelker.de> Date: Sat, 20 Oct 2018 00:56:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181019224822.7994ce73bb7009249d7d2a14@schrader-schulte.de> Content-Type: multipart/mixed; boundary="------------5100289341C339E29CA9CEC8" Content-Language: en-US X-Provags-ID: V03:K1:Q2U93Hl1wvQ+WNwwnqxZiireI/I15ZhwUOAsrCaZpjH/JLv6qwu biRy2OPQjyvqCYVUFnNKKbOW7W7CMfG33cUuhotqbT7im8GgJ1YMvZk5wRFCL5d5FFf4C/p aSdZYplPDq5XbVOsO6T7DGtFxhIWIEHr4fRGEc01nMnqf2ovt+E3YB4qAYtaeBvPutpJDAX LhSMio3A0wnLe7j/fktJA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V01:K0:C589IYf2cQo=:g+J5tL3unwgdZffDFNIPtV V42DTmzyV9QanzskPVWHcxkR2NkyYI9/htmZSGDBYBZIgsHBwmPCttDQf8HDJf+pUfnjsGw/3 TcjW9vMF+a3Uj9xjW37N9yBrmL1zEF3ElqWQTKVbnH9tWsXQyEG0BrmI4QFkWtQPEu24yFoh+ UDIpXUhF0c8Nf/46EcJE8ZiwZgQH2lNDd0PapojaZNO3aEYduNYqmoxKrxuicLeQlZ62p5Zq+ FwwJ8Vq4Tw4XMoVZdROpZU5wVoRIRh0jDzxPSH1cLrCrvi3bxUcIPrm/6c4ERkCEbJ3tdQs54 fAwr7D6UOUipEgi2ZkmJT+WAuZT2hQHBOq+tuqMto1TXpTIhyorzu64vvLDQlz66pya4xIoQB NWesLpKnzBmXFFnxuubkj44oukioepYbAhxEo4meNXClXXcGXQNUlOR02b46kdYYYgAFUE4aA h6j5ufZLaSzQcQXlRdUqn0Fvc5vctbNdNkK+Snw6630zfXP/jklXqVR19fRZ+tIQl+A0jCkwl dXF8+DcwATo931Td/d0jJj4HBNHcZWjdLUFW9cmHlZqTwiZ5R8lf/kavafCeNeSmoHd53q37S i+W0/0ZTISmLQyUJ0xdbhd1mTb/oNpGSOR6hEV3mQuz3gsjuHNf+DmEcLu9Br4XMmsxcGGD00 pQUzZREdGuR1iYvWv/QEn9qGd+gNgPMUQ6mFZhNgeS2Wu2gpuAbiRwnhGZ+3xxh3p/u4= X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 33097 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This is a multi-part message in MIME format. --------------5100289341C339E29CA9CEC8 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 10/19/18 10:48 PM, Martin Schulte wrote: > Hello coreutils maintainers, > > test in coreutils 8.30 supports the unary -a test (is the same as -e) but > this is not listed on the manpage (in bash 4.4.12 "help test" does list > it). > > I can imagine good reasons to kick out the unary -a but I think it > then should be kicked out of program and man page (or it should be listed > in the man page, maybe as deprecated). Good spot, thanks for the report. The '-a FILE' primary is supported since "the beginning", and even the POSIX spec mentions this unlucky thing: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html An early proposal used the KornShell -a primary (with the same meaning), but this was changed to -e because there were concerns about the high probability of humans confusing the -a primary with the -a binary operator. I don't think we can remove that primary without breaking some scripts, so it's probably best to document it. The attached, proposed patch add documentation both in the man and texinfo format. Comments? Have a nice day, Berny --------------5100289341C339E29CA9CEC8 Content-Type: text/x-patch; name="0001-doc-document-highly-discouraged-test-a-FILE-primary.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0001-doc-document-highly-discouraged-test-a-FILE-primary.pat"; filename*1="ch" =46rom 0a7d57e7fc9fdfdf3e7f6f4e5c3a5a9a7891c099 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Sat, 20 Oct 2018 00:49:30 +0200 Subject: [PATCH] doc: document (highly discouraged) 'test -a FILE' primar= y * doc/coreutils.texi (node File type tests): Add a sentence about the supported-yet-discouraged primary '-a FILE'. * src/test.c (usage): Likewise. The documentation of that primary was missing since "the beginning". Fixes https://bugs.gnu.org/33097 --- doc/coreutils.texi | 4 ++++ src/test.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 512443aa6..0a7aab133 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -13007,6 +13007,10 @@ terminal. =20 @end table =20 +This implementation of @command{test} also supports the primary @samp{-a= FILE} +as an alias of @samp{-e FILE} for compatibility with some shell implemen= tations, +e.g. @command{bash}, but its use is highly discouraged both to avoid amb= iguity +and for portability reasons. =20 @node Access permission tests @subsection Access permission tests diff --git a/src/test.c b/src/test.c index aae45012a..f255d06b1 100644 --- a/src/test.c +++ b/src/test.c @@ -792,6 +792,9 @@ INTEGER may also be -l STRING, which evaluates to the= length of STRING.\n\ \n\ NOTE: Binary -a and -o are inherently ambiguous. Use 'test EXPR1 && tes= t\n\ EXPR2' or 'test EXPR1 || test EXPR2' instead.\n\ +This implementation of 'test' also supports the primary '-a FILE' as an\= n\ +alias of '-e FILE' for compatibility reasons, but its use is highly\n\ +discouraged for obvious reasons.\n\ "), stdout); fputs (_("\ \n\ --=20 2.19.1 --------------5100289341C339E29CA9CEC8-- From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 19 19:09:27 2018 Received: (at 33097) by debbugs.gnu.org; 19 Oct 2018 23:09:27 +0000 Received: from localhost ([127.0.0.1]:59975 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gDdtW-0004cd-WF for submit@debbugs.gnu.org; Fri, 19 Oct 2018 19:09:27 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:41793) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gDdtU-0004cP-TB for 33097@debbugs.gnu.org; Fri, 19 Oct 2018 19:09:25 -0400 Received: by mail-pl1-f193.google.com with SMTP id p5-v6so1552931plq.8 for <33097@debbugs.gnu.org>; Fri, 19 Oct 2018 16:09:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=4Cvewd8MTM/gZx6FgXWrIThjH1jfFHwvLG0MjsD99A4=; b=Tk/xCPqhhddv+JyF9bg1Wh/a3uGuLckXaz7EJZrrLunTC54hX7Xb76YArrZkvFK7HH mJcjhy+D1grk1nLxkOXiF1Ui50frHR3KRiX8l93lnLm6fYt8CFK5ryUdOsY7SbIvMb9V fMMpb0J8pVxlm2AQUK2a0ey4QKW3ssViUoVcDXkq/AR2NK6DajTz0QUklDkb015EMaHf JQP+MFqlLK7Py16IiDU/zIiXLe02ylsnKvriG4KmtJxy+kfJaVB2reFQlIUXNP1ZyqS2 F3zYz0ZCwS2Te/XdMy44P6B7/8D+btfxdLVPJKpeUqzvPV9A2lfOnK0vY1h4jeJ7SmrK iYQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=4Cvewd8MTM/gZx6FgXWrIThjH1jfFHwvLG0MjsD99A4=; b=p4h5UDEEJVk3yMu0h1bJeAREpwre4/Ozsda3FtMiJ91WcNgHFISWBmcfON+BOh8cEB kZaSYSQRlzBKcBV2d+vBeZDCd0tC3mKL9whyHJB8h0FtQxUL66iH7TtDcv/R6Vt8XRxn 6UPGV3WP9hbbodi+Hb6H6VHw5gWB2G8oa0IGwZVFGNmmvUXyXLilfmnxgyS/dQetTpmq +7z1cgLqj3AvHKhGXettFHOHWy8gjzh4Hq8mB0SDjbLOCNsKuOmXwDNRM3NSjMpc8z8p 29cE0p6mDtxa38uY0LVoFno4EgYJIghJe/yEKj6DhaNXd70B9PODf5H2gK/5MyPehOUc piPA== X-Gm-Message-State: ABuFfoiVRlv0C9KEFWvT4vg6L/ZAgoRWa1FNH5WYtoKfXf3ub6zX+e36 Gpi/3xE2pI/jDI4WM/kK7+QHuzeRAqE= X-Google-Smtp-Source: ACcGV63+C1EG7IfCXYuFEdDpQUX10MVuc51t6BAqHbO0NWx5Zgg/4xm2OJVwkhdCUBSgaQnJXR26LQ== X-Received: by 2002:a17:902:9004:: with SMTP id a4-v6mr35299962plp.166.1539990558535; Fri, 19 Oct 2018 16:09:18 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id k12-v6sm7812527pgr.81.2018.10.19.16.09.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Oct 2018 16:09:17 -0700 (PDT) Subject: Re: bug#33097: test has filetest -a but man page doesn't list it To: Bernhard Voelker , Martin Schulte , 33097@debbugs.gnu.org References: <20181019224822.7994ce73bb7009249d7d2a14@schrader-schulte.de> <6153c275-fc83-35bb-bbff-377d75ba3b57@bernhard-voelker.de> From: Assaf Gordon Message-ID: <717b9bc0-dac4-9dc4-8455-120c5f3068d5@gmail.com> Date: Fri, 19 Oct 2018 17:09:15 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <6153c275-fc83-35bb-bbff-377d75ba3b57@bernhard-voelker.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 33097 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Bernhard, On 19/10/18 04:56 PM, Bernhard Voelker wrote: > On 10/19/18 10:48 PM, Martin Schulte wrote: > > The '-a FILE' primary is supported since "the beginning", and even the > POSIX spec mentions this unlucky thing: [...] > I don't think we can remove that primary without breaking some scripts, > so it's probably best to document it. > The attached, proposed patch add documentation both in the man and > texinfo format. > > Comments? > I just noticed this old bug: https://bugs.gnu.org/15278 Where Eric notes that coreutils' unary -a is incorrect under some very specific circumstances - perhaps it's worth mentioning that as well (unless someone wants to fix it, though it's been 5 years...) -assaf From debbugs-submit-bounces@debbugs.gnu.org Sat Oct 20 20:10:04 2018 Received: (at 33097) by debbugs.gnu.org; 21 Oct 2018 00:10:04 +0000 Received: from localhost ([127.0.0.1]:33638 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gE1Jj-00060Z-J7 for submit@debbugs.gnu.org; Sat, 20 Oct 2018 20:10:03 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:53354) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gE1Jh-000600-Hd for 33097@debbugs.gnu.org; Sat, 20 Oct 2018 20:10:02 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 4121216005D; Sat, 20 Oct 2018 17:09:56 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 40k3xcYk8cLU; Sat, 20 Oct 2018 17:09:55 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 8F725160061; Sat, 20 Oct 2018 17:09:55 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id L1RhLE7AjpdT; Sat, 20 Oct 2018 17:09:55 -0700 (PDT) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 62B1616005D; Sat, 20 Oct 2018 17:09:55 -0700 (PDT) Subject: Re: bug#33097: test has filetest -a but man page doesn't list it To: Bernhard Voelker , Martin Schulte , 33097@debbugs.gnu.org References: <20181019224822.7994ce73bb7009249d7d2a14@schrader-schulte.de> <6153c275-fc83-35bb-bbff-377d75ba3b57@bernhard-voelker.de> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: Date: Sat, 20 Oct 2018 17:09:55 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <6153c275-fc83-35bb-bbff-377d75ba3b57@bernhard-voelker.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 33097 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Bernhard Voelker wrote: > I don't think we can remove that primary without breaking some scripts, > so it's probably best to document it. I have the opposite impression. Any scripts using this confusing -a operator are already broken, and we should phase it out. Not that anybody actually *uses* coreutils "test -a". From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 21 04:29:24 2018 Received: (at 33097) by debbugs.gnu.org; 21 Oct 2018 08:29:24 +0000 Received: from localhost ([127.0.0.1]:33758 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gE96v-0003Pi-EW for submit@debbugs.gnu.org; Sun, 21 Oct 2018 04:29:24 -0400 Received: from s5.ds-gmbh.de ([91.184.37.130]:48882) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gE96t-0003PZ-Lg for 33097@debbugs.gnu.org; Sun, 21 Oct 2018 04:29:20 -0400 Received: from martnix4 (aftr-37-201-193-234.unity-media.net [37.201.193.234]) by s5.ds-gmbh.de (Postfix) with ESMTPA id 922851D4107; Sun, 21 Oct 2018 10:30:16 +0200 (CEST) Date: Sun, 21 Oct 2018 10:29:09 +0200 From: Martin Schulte To: 33097@debbugs.gnu.org Subject: Re: bug#33097: test has filetest -a but man page doesn't list it Message-Id: <20181021102909.6a7e0798dec953ef62fbe515@schrader-schulte.de> In-Reply-To: References: <20181019224822.7994ce73bb7009249d7d2a14@schrader-schulte.de> <6153c275-fc83-35bb-bbff-377d75ba3b57@bernhard-voelker.de> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 33097 Cc: Bernhard Voelker , Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello! Paul Eggert wrote: > Bernhard Voelker wrote: > > I don't think we can remove that primary without breaking some > > scripts, so it's probably best to document it. > > I have the opposite impression. Any scripts using this confusing -a > operator are already broken, and we should phase it out. Not that > anybody actually *uses* coreutils "test -a". I second this - but I think it's even more important that the test from coreutils and the bash builtin behave/are documented the same way. "help test" lists "-a" as file test, but when negated the bash builtin behaves different ("wronger" from my point of view) than the coreutils version (and even different from the "-e" in both implementations) - see attached output. coreutils: test ! -a file -> test ! ( -a file ) bash: test ! -a file -> test ( ! ) -a ( file ) Best regards, Martin schulte@martnix4:~/langs/sh$ cat minus-a #!/bin/bash set -o nounset file=/etc/passwd echo $BASH_VERSION /usr/bin/[ --version | head -1 for cmd in test /usr/bin/test do for op in -a -e do printf "%-30s -> " "$cmd ! $op $file" ; $cmd ! $op $file ; echo $? done done | cat -n schulte@martnix4:~/langs/sh$ ./minus-a 4.4.12(1)-release [ (GNU coreutils) 8.26 1 test ! -a /etc/passwd -> 0 2 test ! -e /etc/passwd -> 1 3 /usr/bin/test ! -a /etc/passwd -> 1 4 /usr/bin/test ! -e /etc/passwd -> 1 From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 21 04:39:26 2018 Received: (at 33097) by debbugs.gnu.org; 21 Oct 2018 08:39:26 +0000 Received: from localhost ([127.0.0.1]:33763 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gE9Gf-0003jG-VX for submit@debbugs.gnu.org; Sun, 21 Oct 2018 04:39:26 -0400 Received: from s5.ds-gmbh.de ([91.184.37.130]:47174) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gE9Ge-0003j5-1x for 33097@debbugs.gnu.org; Sun, 21 Oct 2018 04:39:24 -0400 Received: from martnix4 (aftr-37-201-193-234.unity-media.net [37.201.193.234]) by s5.ds-gmbh.de (Postfix) with ESMTPA id AA05B1D4107; Sun, 21 Oct 2018 10:40:21 +0200 (CEST) Date: Sun, 21 Oct 2018 10:39:21 +0200 From: Martin Schulte To: 33097@debbugs.gnu.org Subject: Re: bug#33097: test has filetest -a but man page doesn't list it Message-Id: <20181021103921.f8b3e4d0303110b69c3ff4e9@schrader-schulte.de> In-Reply-To: References: <20181019224822.7994ce73bb7009249d7d2a14@schrader-schulte.de> <6153c275-fc83-35bb-bbff-377d75ba3b57@bernhard-voelker.de> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 33097 Cc: Bernhard Voelker , Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello again! Paul Eggert wrote: > Bernhard Voelker wrote: > > I don't think we can remove that primary without breaking some > > scripts, so it's probably best to document it. > > I have the opposite impression. Any scripts using this confusing -a > operator are already broken, and we should phase it out. Not that > anybody actually *uses* coreutils "test -a". Maybe even more important than the previous arguments - there's no filetest "-a" in the POSIX standard: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html Best regards, Martin From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 21 19:07:23 2018 Received: (at 33097) by debbugs.gnu.org; 21 Oct 2018 23:07:23 +0000 Received: from localhost ([127.0.0.1]:34861 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gEMoT-0007Mg-IA for submit@debbugs.gnu.org; Sun, 21 Oct 2018 19:07:23 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:46845) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gEMoQ-0007MR-TP for 33097@debbugs.gnu.org; Sun, 21 Oct 2018 19:07:11 -0400 Received: from [192.168.101.10] ([91.12.166.119]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MOzGc-1fxxU809Xw-00PKvD; Mon, 22 Oct 2018 01:06:52 +0200 Received: from [192.168.101.10] ([91.12.166.119]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MOzGc-1fxxU809Xw-00PKvD; Mon, 22 Oct 2018 01:06:52 +0200 Subject: Re: bug#33097: test has filetest -a but man page doesn't list it To: Paul Eggert , Martin Schulte , 33097@debbugs.gnu.org References: <20181019224822.7994ce73bb7009249d7d2a14@schrader-schulte.de> <6153c275-fc83-35bb-bbff-377d75ba3b57@bernhard-voelker.de> From: Bernhard Voelker Openpgp: preference=signencrypt Autocrypt: addr=mail@bernhard-voelker.de; prefer-encrypt=mutual; keydata= xsBNBFPirzMBCACyzYldTjQ4ufFOkByY5Nn5USb5GFoL48nWBwNHjd9KUbtRRNlQiPNKd6hK Gvd3BGi5aoFKA4ytfRk6jbAbW3jVb3R8wYaV08mOy4KVEKxqN4bxsXlMjNChXVR+rtKDmfI+ oPTL+cPH2X6gW4W02IRbVw0uUhNm6zEedC/gNrY/mTlf1enZ46jxZ7BTUZaG+kx38UMISIMB zSzLRtdkwgmHj4jS3p1fF2cwRqLclIfMjKGpbNFPEXeXKWrCLcqHw78795eAR9q0YvrDkfIn GdDBwfb3VM4NdulwIFzvYZMSXvSbbyPLB5YkHU5aAWQHUse4WlfT5ccDpbzUYldRAvF9ABEB AAHNK0Jlcm5oYXJkIFZvZWxrZXIgPG1haWxAYmVybmhhcmQtdm9lbGtlci5kZT7CwHkEEwEC ACMFAlPirzMCGwMHCwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIXgAAKCRBGUC73lpFxle5wCACC dbs0QaJ0vR3Sff2cKdTk41rUq3YfWngsR///IOU0C5DdkePmCnJE/lUsUy0LRTxcUDLxQR+x QHU8ssRT0JUO9726dI3miy36UdsgmBYaOtLvQcidGmW1R7o0PYYf04+TFtyqKgngOUBPpMgR 6o4UsQxy/OD4bN1WDqOgIjL+D/qJpkKmgp6L6+hhaBCpiOFKRmmV7YyQ3SqVlfQNiHs5ZtkR nXpIjgZARV+GllKucI17bO0CGmTJZ1tstVy0+W3DQT1lbBkTTc++5LONM99D3jjn23l1ocOp folR53F7I4cb2RNfT23v1I59RH37lB9wMOqrKj0UjYAC2YoPGQ3BzsBNBFPirzMBCADXLWWp QihBldY6reca8ZKdc3T9qXEOa3akE3DWKztIBmNJhtYOjmpLYajQTkGa7UoJTnbmZE2Rn6ZE oNnvb0gcFNAIcY95KOI+bjOR8HEgh4cx2REXh6L6olIgyXqt/KFusE4wtVZAFxZl+30HzN6n D+1HvrjXxPJRX6MsIYOYyyX9/6OofwJK6QHODYGp8WL2olHDnmsXg4AT6Wlr7qKpKrQELlcF R4xkvdmgL/Ghw/tK0yJTxMIcewCCZWLPOXRmFRbvAadZWPAgVsJ63siNyUlVnVMSzDgTJl+s l/DMabXpqrJQx3/1Yy6mTaDs3XZT/wmBKaTLXx/LByaPxQQ7ABEBAAHCwF8EGAECAAkFAlPi rzMCGwwACgkQRlAu95aRcZWVPwgAqZT6iTXkoP37wYb41323RzhBcJ8JSk4cyBDBUXX0lMrM 3qhiClKG7phpxVdu817Gwc6Hsecg7FfjQAV8MHQ0ZFeEFdk3b2rKBqfsStc+h49/xF3Fb+if CzR9qeQF82fMSxkg18++7hMcHCMO/hPZ/Q0xRi+lrSr2QKDJQuLzSyVU14TxrCkevZjEhtma VNvcJlJzCbiBXee9Fpc5jITUXPFG8E8dxqo1n+duOyIMgozrAnzP7X5V/Ob/Ozf/aGGX9+Jd inyfCX18nWcHALKMU/36Eua/ylalf/2c2YkBp9KCLVmGgPkUgW52EeRPgroIsiwu+rwCSV6Z UyCJ+OymCg== Message-ID: <1edec5cf-be91-d3aa-dd0d-ffc6c999c08c@bernhard-voelker.de> Date: Mon, 22 Oct 2018 01:06:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------A1E44CC72F46F87251CE6A3E" Content-Language: en-US X-Provags-ID: V03:K1:BxP/o2W3Z2/NqmJNmZix0IRvMDQnf0NcqkKwN8UhsksxVteagtl GIcC/ByW7zGFabLIAClx1aIMzDChXEqTj/Dlc0xNyD4GRyXSJJYMNcTIJqsT6jHFh6wyaSW ogvgECN3xycXBMGBvOMcNQhq1qGAmM2erdwZTBv2ECCjJW+WAaAqFB9qtcD7IFAgsgxm8Sq p1uhYfBaQYzRF/ym9mXGw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V01:K0:2y/cnK2g0y4=:K9s5Xq2GCBhIGASue0S87F pcZ1PBXap+CcJF6EjUCpDC+xvKKQbiu4b3+0JNgTFesjcYwZCj5F1/XlkSK4WO6o0YN0oOXZv H8sc+ct/9FLHgDMi1WgePzCKTCbcUz0mU1ueucvowcUWT+KYvmiXf0GpmlcLYVviYBVjQl7KH 4Pawv4J+lDlfekL2f0bdvglDe1vUn9YpsW/K3ONWahtmhwnIIXi+msyWusMhgJJwD+pH2a+E8 /uyxerP7odLLNUCXcGGL4iehg2H0ksozX0TUS/xmlHskjQ+5zu0wggQMbUdp0pRo3fdyltit5 vDD1F8ydkebQDyLjgmkoHMUoE8JsimRDnfgqSWzQ5XqqzIunlVxpl8h1xcmN+ovpKB7Zasmq6 7eS9grnXchzDlz0LsnTjir5xTQSChxRve2H7D+nTw/Qyak2cZl5oBJ8ZZekN7sRr+1xh85qxm 0M/vU0DQB3X12ufVu40WXrx4GK2cmMHdxr5V9R/seGcrEzxUCcpZLYBlTMjZi3/fxsNZ8QYGM c2o5VyamJvApj8UXcc5rH8CT2ai+JbyWXnZvOBse/F3mho7Puoj0UShbnM3LqXVLeZ/EX6+U1 xv4uQniuKouS4E2memnE+vi484dR2QqRTuUWNmL9zUudGpJ8Kce0uHDoavsdem0TfjkhuZuUr NUnHM7JTrUsenTRnM3sH/dPT0N25bfMzShr30hp6k1ymC+dHH6lAOtAkpP7PBCDXZtvU= X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 33097 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) This is a multi-part message in MIME format. --------------A1E44CC72F46F87251CE6A3E Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit On 10/21/18 2:09 AM, Paul Eggert wrote: > I have the opposite impression. Any scripts using this confusing -a operator are > already broken, and we should phase it out. Not that anybody actually *uses* > coreutils "test -a". Done with the attached 1st patch. The 2nd patch is a cleanup avoiding the redundant checking of unary operators in test_unop and unary_operator. The 3rd patch adds support for 'test -N FILE' as in bash. Please check (on various platforms / file systems if possible). Thanks & have a nice day, Berny --------------A1E44CC72F46F87251CE6A3E Content-Type: text/x-patch; name="0001-test-remove-support-for-the-ambigous-a-unary-operato.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename*0="0001-test-remove-support-for-the-ambigous-a-unary-operato.pa"; filename*1="tch" =46rom 3dc474f71275d5fdd18a028ede19c507e1ecd830 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Sun, 21 Oct 2018 21:17:31 +0200 Subject: [PATCH 1/3] test: remove support for the ambigous -a unary opera= tor * src/test.c (unary_operator): Remove case 'a'. (test_unop): Likewise. * NEWS (Changes in behavior): Document the change. Discussed at https://bugs.gnu.org/33097 --- NEWS | 7 +++++++ src/test.c | 5 ++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index ae9667e61..a2b733d38 100644 --- a/NEWS +++ b/NEWS @@ -16,6 +16,13 @@ GNU coreutils NEWS = -*- outline -*- approach is still used in situations where hard links to directories are allowed (e.g., NetBSD when superuser). =20 +** Changes in behavior + + 'test -a FILE' is not supported anymore. Long ago, there were concern= s about + the high probability of humans confusing the -a primary with the -a bi= nary + operator, so POSIX changed this to 'test -e FILE'. Scripts using it w= ere + already broken and non-portable; the -a unary operator was never docum= ented. + ** New features =20 id now supports specifying multiple users. diff --git a/src/test.c b/src/test.c index aae45012a..339a84075 100644 --- a/src/test.c +++ b/src/test.c @@ -406,8 +406,7 @@ unary_operator (void) pos right past it. This means that pos - 1 is the location of = the argument. */ =20 - case 'a': /* file exists in the file system? */ - case 'e': + case 'e': /* file exists in the file system? */ unary_advance (); return stat (argv[pos - 1], &stat_buf) =3D=3D 0; =20 @@ -586,7 +585,7 @@ test_unop (char const *op) =20 switch (op[1]) { - case 'a': case 'b': case 'c': case 'd': case 'e': + case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'k': case 'n': case 'o': case 'p': case 'r': case 's': case 't': case 'u': case 'w': case 'x': case 'z': --=20 2.19.1 --------------A1E44CC72F46F87251CE6A3E Content-Type: text/x-patch; name="0002-test-simplify-redundant-code.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0002-test-simplify-redundant-code.patch" =46rom 6088beb33c64c1fad7f1ec607335bf227fd831d0 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Sun, 21 Oct 2018 21:56:43 +0200 Subject: [PATCH 2/3] test: simplify redundant code Remove the function 'test_unop', as the cases therein are redundant to those handled by 'unary_operator'; exception: the cases 'o' and 'N': they had been present in test_unop and handling the commands test -N STR test -o STR and test x =3D x -a -N STR test x =3D x -a -o STR which ran into an error later on anyway. With this commit, the error diagnostic will change from ... $ /usr/bin/test -N STR /usr/bin/test: extra argument '-N' $ /usr/bin/test -o STR /usr/bin/test: extra argument '-o' =2E.. to ... $ src/test -N STR src/test: '-N': unary operator expected $ src/test -o STR src/test: '-o': unary operator expected * src/test.c (test_unop): Remove. (unary_operator): Fail with test_syntax_error in the default case. (term): Directly call unary_operator. (two_arguments): Likewise. * tests/misc/test-diag.pl: Adjust error diagnostic. --- src/test.c | 34 +++------------------------------- tests/misc/test-diag.pl | 4 ++-- 2 files changed, 5 insertions(+), 33 deletions(-) diff --git a/src/test.c b/src/test.c index 339a84075..9005b1962 100644 --- a/src/test.c +++ b/src/test.c @@ -72,7 +72,6 @@ static int pos; /* The offset of the current argument = in ARGV. */ static int argc; /* The number of arguments present in ARGV. */ static char **argv; /* The argument list. */ =20 -static bool test_unop (char const *s); static bool unary_operator (void); static bool binary_operator (bool); static bool two_arguments (void); @@ -258,12 +257,7 @@ term (void) =20 /* It might be a switch type argument. */ else if (argv[pos][0] =3D=3D '-' && argv[pos][1] && argv[pos][2] =3D=3D= '\0') - { - if (test_unop (argv[pos])) - value =3D unary_operator (); - else - test_syntax_error (_("%s: unary operator expected"), quote (argv= [pos])); - } + value =3D unary_operator (); else { value =3D (argv[pos][0] !=3D '\0'); @@ -399,6 +393,7 @@ unary_operator (void) switch (argv[pos][1]) { default: + test_syntax_error (_("%s: unary operator expected"), quote (argv[p= os])); return false; =20 /* All of the following unary operators use unary_advance (), whic= h @@ -576,26 +571,6 @@ expr (void) return or (); /* Same with this. */ } =20 -/* Return true if OP is one of the test command's unary operators. */ -static bool -test_unop (char const *op) -{ - if (op[0] !=3D '-') - return false; - - switch (op[1]) - { - case 'b': case 'c': case 'd': case 'e': - case 'f': case 'g': case 'h': case 'k': case 'n': - case 'o': case 'p': case 'r': case 's': case 't': - case 'u': case 'w': case 'x': case 'z': - case 'G': case 'L': case 'O': case 'S': case 'N': - return true; - default: - return false; - } -} - static bool one_argument (void) { @@ -616,10 +591,7 @@ two_arguments (void) && argv[pos][1] !=3D '\0' && argv[pos][2] =3D=3D '\0') { - if (test_unop (argv[pos])) - value =3D unary_operator (); - else - test_syntax_error (_("%s: unary operator expected"), quote (argv= [pos])); + value =3D unary_operator (); } else beyond (); diff --git a/tests/misc/test-diag.pl b/tests/misc/test-diag.pl index 91356ef56..f543f9f09 100755 --- a/tests/misc/test-diag.pl +++ b/tests/misc/test-diag.pl @@ -26,8 +26,8 @@ use strict; my @Tests =3D ( # In coreutils-5.93, this diagnostic lacked the newline. - ['o', '-o arg', {ERR =3D> "test: extra argument '-o'\n"}, - {ERR_SUBST =3D> 's!^.*:!test:!'}, + ['o', '-o arg', {ERR =3D> "test: '-o': unary operator expected\n"},= + {ERR_SUBST =3D> 's!^.*test:!test:!'}, {EXIT =3D> 2}], ); =20 --=20 2.19.1 --------------A1E44CC72F46F87251CE6A3E Content-Type: text/x-patch; name="0003-test-add-N-unary-operator.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0003-test-add-N-unary-operator.patch" =46rom ab7719540668240baf734b44a63bff270557c0a6 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Mon, 22 Oct 2018 00:54:51 +0200 Subject: [PATCH 3/3] test: add -N unary operator Bash knows 'test -N FILE'. Add it to GNU 'test' as well. * src/test.c (unary_operator): Add a case for 'N'. (usage): Document it. * doc/coreutils.texi (node File characteristic tests): Likewise. * NEWS (New features): Likewise. * tests/misc/test-N.sh: Add a test. * tests/local.mk (all_tests): Reference it. --- NEWS | 3 +++ doc/coreutils.texi | 6 ++++++ src/test.c | 11 +++++++++++ tests/local.mk | 1 + tests/misc/test-N.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 63 insertions(+) create mode 100755 tests/misc/test-N.sh diff --git a/NEWS b/NEWS index a2b733d38..a8fa5f2e4 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,9 @@ GNU coreutils NEWS -= *- outline -*- =20 id now supports specifying multiple users. =20 + test now supports the '-N FILE' unary operator (like e.g. bash) to che= ck + whether FILE exists and has been modified since it was last read. + =20 * Noteworthy changes in release 8.30 (2018-07-01) [stable] =20 diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 512443aa6..30155bb86 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -13099,6 +13099,12 @@ True if @var{file1} is older (according to modif= ication date) than True if @var{file1} and @var{file2} have the same device and inode numbers, i.e., if they are hard links to each other. =20 +@item -N @var{file} +@opindex -N +@cindex mtime-greater-atime file check +True if @var{file} exists and has been modified (mtime) since it was +last read (atime). + @end table =20 =20 diff --git a/src/test.c b/src/test.c index 9005b1962..7ed797f17 100644 --- a/src/test.c +++ b/src/test.c @@ -417,6 +417,16 @@ unary_operator (void) unary_advance (); return euidaccess (argv[pos - 1], X_OK) =3D=3D 0; =20 + case 'N': /* File exists and has been modified since it was last re= ad? */ + { + unary_advance (); + if (stat (argv[pos - 1], &stat_buf) !=3D 0) + return false; + struct timespec atime =3D get_stat_atime (&stat_buf); + struct timespec mtime =3D get_stat_mtime (&stat_buf); + return (timespec_cmp (mtime, atime) > 0); + } + case 'O': /* File is owned by you? */ { unary_advance (); @@ -741,6 +751,7 @@ EXPRESSION is true or false and sets exit status. It= is one of:\n\ "), stdout); fputs (_("\ -L FILE FILE exists and is a symbolic link (same as -h)\n\ + -N FILE FILE exists and has been modified since it was last read\n= \ -O FILE FILE exists and is owned by the effective user ID\n\ -p FILE FILE exists and is a named pipe\n\ -r FILE FILE exists and read permission is granted\n\ diff --git a/tests/local.mk b/tests/local.mk index 47c6b9537..84d346979 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -408,6 +408,7 @@ all_tests =3D \ tests/misc/tac-2-nonseekable.sh \ tests/misc/tail.pl \ tests/misc/tee.sh \ + tests/misc/test-N.sh \ tests/misc/test-diag.pl \ tests/misc/time-style.sh \ tests/misc/timeout.sh \ diff --git a/tests/misc/test-N.sh b/tests/misc/test-N.sh new file mode 100755 index 000000000..36eae8e8c --- /dev/null +++ b/tests/misc/test-N.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# Test 'test -N file'. + +# Copyright (C) 2018 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see .= + +. "${srcdir=3D.}/tests/init.sh"; path_prepend_ ./src +print_ver_ test + +# For a freshly touched file, atime should equal mtime: 'test -N' return= s 1. +touch file || framework_failure_ +stat file +returns_ 1 env test -N file || fail=3D1 + +# Set access time to yesterday at noon: 'test -N' returns 0. +touch -a -d "12:00 today -1 days" file || framework_failure_ +stat file +env test -N file || fail=3D1 + +# Set mtime to the day before yesterday: 'test -N' returns 1; +touch -m -d "12:00 today -2 days" file || framework_failure_ +stat file +returns_ 1 env test -N file || fail=3D1 + +# Now modify the file: 'test -N' returns 0. +> file || framework_failure_ +stat file +env test -N file || fail=3D1 + +Exit $fail --=20 2.19.1 --------------A1E44CC72F46F87251CE6A3E-- From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 22 02:16:06 2018 Received: (at 33097) by debbugs.gnu.org; 22 Oct 2018 06:16:06 +0000 Received: from localhost ([127.0.0.1]:35038 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gETVW-0002vo-7y for submit@debbugs.gnu.org; Mon, 22 Oct 2018 02:16:06 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:41921) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gETVS-0002v7-T3 for 33097@debbugs.gnu.org; Mon, 22 Oct 2018 02:16:03 -0400 Received: from [192.168.101.10] ([91.12.166.119]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N6KML-1fYRfh1Gyv-016cUL; Mon, 22 Oct 2018 08:15:56 +0200 Received: from [192.168.101.10] ([91.12.166.119]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N6KML-1fYRfh1Gyv-016cUL; Mon, 22 Oct 2018 08:15:56 +0200 Subject: Re: bug#33097: test has filetest -a but man page doesn't list it To: Assaf Gordon , Martin Schulte , 33097@debbugs.gnu.org References: <20181019224822.7994ce73bb7009249d7d2a14@schrader-schulte.de> <6153c275-fc83-35bb-bbff-377d75ba3b57@bernhard-voelker.de> <717b9bc0-dac4-9dc4-8455-120c5f3068d5@gmail.com> From: Bernhard Voelker Openpgp: preference=signencrypt Autocrypt: addr=mail@bernhard-voelker.de; prefer-encrypt=mutual; keydata= xsBNBFPirzMBCACyzYldTjQ4ufFOkByY5Nn5USb5GFoL48nWBwNHjd9KUbtRRNlQiPNKd6hK Gvd3BGi5aoFKA4ytfRk6jbAbW3jVb3R8wYaV08mOy4KVEKxqN4bxsXlMjNChXVR+rtKDmfI+ oPTL+cPH2X6gW4W02IRbVw0uUhNm6zEedC/gNrY/mTlf1enZ46jxZ7BTUZaG+kx38UMISIMB zSzLRtdkwgmHj4jS3p1fF2cwRqLclIfMjKGpbNFPEXeXKWrCLcqHw78795eAR9q0YvrDkfIn GdDBwfb3VM4NdulwIFzvYZMSXvSbbyPLB5YkHU5aAWQHUse4WlfT5ccDpbzUYldRAvF9ABEB AAHNK0Jlcm5oYXJkIFZvZWxrZXIgPG1haWxAYmVybmhhcmQtdm9lbGtlci5kZT7CwHkEEwEC ACMFAlPirzMCGwMHCwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIXgAAKCRBGUC73lpFxle5wCACC dbs0QaJ0vR3Sff2cKdTk41rUq3YfWngsR///IOU0C5DdkePmCnJE/lUsUy0LRTxcUDLxQR+x QHU8ssRT0JUO9726dI3miy36UdsgmBYaOtLvQcidGmW1R7o0PYYf04+TFtyqKgngOUBPpMgR 6o4UsQxy/OD4bN1WDqOgIjL+D/qJpkKmgp6L6+hhaBCpiOFKRmmV7YyQ3SqVlfQNiHs5ZtkR nXpIjgZARV+GllKucI17bO0CGmTJZ1tstVy0+W3DQT1lbBkTTc++5LONM99D3jjn23l1ocOp folR53F7I4cb2RNfT23v1I59RH37lB9wMOqrKj0UjYAC2YoPGQ3BzsBNBFPirzMBCADXLWWp QihBldY6reca8ZKdc3T9qXEOa3akE3DWKztIBmNJhtYOjmpLYajQTkGa7UoJTnbmZE2Rn6ZE oNnvb0gcFNAIcY95KOI+bjOR8HEgh4cx2REXh6L6olIgyXqt/KFusE4wtVZAFxZl+30HzN6n D+1HvrjXxPJRX6MsIYOYyyX9/6OofwJK6QHODYGp8WL2olHDnmsXg4AT6Wlr7qKpKrQELlcF R4xkvdmgL/Ghw/tK0yJTxMIcewCCZWLPOXRmFRbvAadZWPAgVsJ63siNyUlVnVMSzDgTJl+s l/DMabXpqrJQx3/1Yy6mTaDs3XZT/wmBKaTLXx/LByaPxQQ7ABEBAAHCwF8EGAECAAkFAlPi rzMCGwwACgkQRlAu95aRcZWVPwgAqZT6iTXkoP37wYb41323RzhBcJ8JSk4cyBDBUXX0lMrM 3qhiClKG7phpxVdu817Gwc6Hsecg7FfjQAV8MHQ0ZFeEFdk3b2rKBqfsStc+h49/xF3Fb+if CzR9qeQF82fMSxkg18++7hMcHCMO/hPZ/Q0xRi+lrSr2QKDJQuLzSyVU14TxrCkevZjEhtma VNvcJlJzCbiBXee9Fpc5jITUXPFG8E8dxqo1n+duOyIMgozrAnzP7X5V/Ob/Ozf/aGGX9+Jd inyfCX18nWcHALKMU/36Eua/ylalf/2c2YkBp9KCLVmGgPkUgW52EeRPgroIsiwu+rwCSV6Z UyCJ+OymCg== Message-ID: Date: Mon, 22 Oct 2018 08:15:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <717b9bc0-dac4-9dc4-8455-120c5f3068d5@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:YffOw2qs24cFU3u4tJmXFUoDOciXjkIYUgtb9dk2pgOumrY03/X l1gcGyjDdTQO8dWhtX6GJLmr+nXZOTJ5RFrp6PzUdWK55psFVjJS34g5EpP7sNIlUpG2Cd4 E9HL0Q0IJZJYB1JFRSU8WKR17KlKDLvARKg6mvWe+9gX2sbvBObrHeuXranyDIckEm2GXtX 1K0rcTDjb77qr7de9KkQg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V01:K0:8iz8jq3c6Zc=:4hg7W/JniMsOKMnjKGtOEX bvyowbsuPv7dCahwiONxbkzWcErPGSdHXAknAH3dIakkEGXlo0aQ/XZfia3nmBlN5AzwlzOS8 UzGyx+CvnMhNAdBG21nt5t0qXGAqz7e4JQEMMAeX1MS9Z4pxUXRKbPHPtp7DFP9Xr3lTXo47O tmZkEv/Ljc1cDivTcvPorWL+GXsaSZgaKnCIwGVpyVNA1cjl6DVWaPMd8znJ5lTgdbZjFqJnd hu96tVbs1PXdJVexnXrshY1s/8qEHIHZL9F9McJ6qYZ2xp5gkqnofCJHr96e0VmIL0DxnrNiQ nJcP7ED64y/VLSIAEGkd6wRNQy5CoQXZdrackoHEf3hbuaZ3RZXkoq+Wci+pYZ+5FPYyjr4gf SAwgqerPcLRw8Cb8dza27EWKDTlsyr0YF7ovchjqikQz1q/5gpjqRY3T7VgBUJ5trFZk/D4BC 9wL07p8ML0ou8bW2H1GMUfykm9QRmmSZAKLda5P4XogXE3kDhnV4WQt583WnsI3hcAmBUnfOn 7uIHzkE/ab0AHIK9P4rawPPOKXDtamaLgzPth0hr42JFMaqE2OWC/ALxUs/h8OxwLhJM0pVRH Th4gx+bwFk9Q1FH3CNNPNl4Iw1QQ/kQks1tvDtszFMDuaInVoyyN+L3Bltuh3jvqqmh+m3S02 JEXviUC6uXDTWDBFv/yQ8qRF3JFruC+oaMzUC7Zb70ILLl3nVtERrKd1Sc7Uz8Q2DKdfWFx3t 1NyITJZuFfUAZhQv X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 33097 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hi Assaf, On 10/20/18 1:09 AM, Assaf Gordon wrote: > Hi Bernhard, > > On 19/10/18 04:56 PM, Bernhard Voelker wrote: >> On 10/19/18 10:48 PM, Martin Schulte wrote: >> >> The '-a FILE' primary is supported since "the beginning", and even the >> POSIX spec mentions this unlucky thing: > [...] >> I don't think we can remove that primary without breaking some scripts, >> so it's probably best to document it. >> The attached, proposed patch add documentation both in the man and >> texinfo format. >> >> Comments? >> > > I just noticed this old bug: > https://bugs.gnu.org/15278 > > Where Eric notes that coreutils' unary -a is incorrect under some very > specific circumstances - perhaps it's worth mentioning that as well > (unless someone wants to fix it, though it's been 5 years...) thanks for mentioning. Now, this bug would go away with the proposed patch #1 in [1] to remove the -a unary operator. FWIW: bash also has a 'test -o SHELLOPT' unary operator to test whether the given SHELLOPT is enabled in the current shell (see 'set -o SHELLOPT'). GNU test also had this -o unary (until patch #2 in [1]), but this never worked well because it ran into an error later on because it ran into thee default case and therefore didn't call 'unary_advance'. [1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=33097#23 Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 22 08:11:55 2018 Received: (at 33097) by debbugs.gnu.org; 22 Oct 2018 12:11:55 +0000 Received: from localhost ([127.0.0.1]:35178 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gEZ3r-0005MA-5W for submit@debbugs.gnu.org; Mon, 22 Oct 2018 08:11:55 -0400 Received: from mail.magicbluesmoke.com ([82.195.144.49]:52314) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gEZ3p-0005M2-6Y for 33097@debbugs.gnu.org; Mon, 22 Oct 2018 08:11:53 -0400 Received: from localhost.localdomain (unknown [109.78.249.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.magicbluesmoke.com (Postfix) with ESMTPSA id D188DB2C3; Mon, 22 Oct 2018 13:11:51 +0100 (IST) Subject: Re: bug#33097: test has filetest -a but man page doesn't list it To: Bernhard Voelker , Paul Eggert , Martin Schulte , 33097@debbugs.gnu.org References: <20181019224822.7994ce73bb7009249d7d2a14@schrader-schulte.de> <6153c275-fc83-35bb-bbff-377d75ba3b57@bernhard-voelker.de> <1edec5cf-be91-d3aa-dd0d-ffc6c999c08c@bernhard-voelker.de> From: =?UTF-8?Q?P=c3=a1draig_Brady?= Message-ID: Date: Mon, 22 Oct 2018 05:11:51 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1edec5cf-be91-d3aa-dd0d-ffc6c999c08c@bernhard-voelker.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 33097 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 21/10/18 16:06, Bernhard Voelker wrote: > On 10/21/18 2:09 AM, Paul Eggert wrote: >> I have the opposite impression. Any scripts using this confusing -a operator are >> already broken, and we should phase it out. Not that anybody actually *uses* >> coreutils "test -a". > > Done with the attached 1st patch. > > The 2nd patch is a cleanup avoiding the redundant checking of unary operators > in test_unop and unary_operator. > > The 3rd patch adds support for 'test -N FILE' as in bash. > Please check (on various platforms / file systems if possible). Very nice. atime has 24 hour resolution on vfat I think, though I think your test should handle that. Also -N should work with common relatime mount option. thanks! Pádraig From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 22 16:18:42 2018 Received: (at 33097) by debbugs.gnu.org; 22 Oct 2018 20:18:42 +0000 Received: from localhost ([127.0.0.1]:36476 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gEgew-0002Yl-5j for submit@debbugs.gnu.org; Mon, 22 Oct 2018 16:18:42 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:35029) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gEgeu-0002YV-BS for 33097@debbugs.gnu.org; Mon, 22 Oct 2018 16:18:40 -0400 Received: from [192.168.101.10] ([91.12.166.119]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MVNEv-1g4YSu1eWF-00SNmu; Mon, 22 Oct 2018 22:18:23 +0200 Received: from [192.168.101.10] ([91.12.166.119]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MVNEv-1g4YSu1eWF-00SNmu; Mon, 22 Oct 2018 22:18:23 +0200 Subject: Re: bug#33097: test has filetest -a but man page doesn't list it To: =?UTF-8?Q?P=c3=a1draig_Brady?= , Paul Eggert , Martin Schulte , 33097@debbugs.gnu.org References: <20181019224822.7994ce73bb7009249d7d2a14@schrader-schulte.de> <6153c275-fc83-35bb-bbff-377d75ba3b57@bernhard-voelker.de> <1edec5cf-be91-d3aa-dd0d-ffc6c999c08c@bernhard-voelker.de> From: Bernhard Voelker Openpgp: preference=signencrypt Autocrypt: addr=mail@bernhard-voelker.de; prefer-encrypt=mutual; keydata= xsBNBFPirzMBCACyzYldTjQ4ufFOkByY5Nn5USb5GFoL48nWBwNHjd9KUbtRRNlQiPNKd6hK Gvd3BGi5aoFKA4ytfRk6jbAbW3jVb3R8wYaV08mOy4KVEKxqN4bxsXlMjNChXVR+rtKDmfI+ oPTL+cPH2X6gW4W02IRbVw0uUhNm6zEedC/gNrY/mTlf1enZ46jxZ7BTUZaG+kx38UMISIMB zSzLRtdkwgmHj4jS3p1fF2cwRqLclIfMjKGpbNFPEXeXKWrCLcqHw78795eAR9q0YvrDkfIn GdDBwfb3VM4NdulwIFzvYZMSXvSbbyPLB5YkHU5aAWQHUse4WlfT5ccDpbzUYldRAvF9ABEB AAHNK0Jlcm5oYXJkIFZvZWxrZXIgPG1haWxAYmVybmhhcmQtdm9lbGtlci5kZT7CwHkEEwEC ACMFAlPirzMCGwMHCwkIBwMCAQYVCAIJCgsEFgIDAQIeAQIXgAAKCRBGUC73lpFxle5wCACC dbs0QaJ0vR3Sff2cKdTk41rUq3YfWngsR///IOU0C5DdkePmCnJE/lUsUy0LRTxcUDLxQR+x QHU8ssRT0JUO9726dI3miy36UdsgmBYaOtLvQcidGmW1R7o0PYYf04+TFtyqKgngOUBPpMgR 6o4UsQxy/OD4bN1WDqOgIjL+D/qJpkKmgp6L6+hhaBCpiOFKRmmV7YyQ3SqVlfQNiHs5ZtkR nXpIjgZARV+GllKucI17bO0CGmTJZ1tstVy0+W3DQT1lbBkTTc++5LONM99D3jjn23l1ocOp folR53F7I4cb2RNfT23v1I59RH37lB9wMOqrKj0UjYAC2YoPGQ3BzsBNBFPirzMBCADXLWWp QihBldY6reca8ZKdc3T9qXEOa3akE3DWKztIBmNJhtYOjmpLYajQTkGa7UoJTnbmZE2Rn6ZE oNnvb0gcFNAIcY95KOI+bjOR8HEgh4cx2REXh6L6olIgyXqt/KFusE4wtVZAFxZl+30HzN6n D+1HvrjXxPJRX6MsIYOYyyX9/6OofwJK6QHODYGp8WL2olHDnmsXg4AT6Wlr7qKpKrQELlcF R4xkvdmgL/Ghw/tK0yJTxMIcewCCZWLPOXRmFRbvAadZWPAgVsJ63siNyUlVnVMSzDgTJl+s l/DMabXpqrJQx3/1Yy6mTaDs3XZT/wmBKaTLXx/LByaPxQQ7ABEBAAHCwF8EGAECAAkFAlPi rzMCGwwACgkQRlAu95aRcZWVPwgAqZT6iTXkoP37wYb41323RzhBcJ8JSk4cyBDBUXX0lMrM 3qhiClKG7phpxVdu817Gwc6Hsecg7FfjQAV8MHQ0ZFeEFdk3b2rKBqfsStc+h49/xF3Fb+if CzR9qeQF82fMSxkg18++7hMcHCMO/hPZ/Q0xRi+lrSr2QKDJQuLzSyVU14TxrCkevZjEhtma VNvcJlJzCbiBXee9Fpc5jITUXPFG8E8dxqo1n+duOyIMgozrAnzP7X5V/Ob/Ozf/aGGX9+Jd inyfCX18nWcHALKMU/36Eua/ylalf/2c2YkBp9KCLVmGgPkUgW52EeRPgroIsiwu+rwCSV6Z UyCJ+OymCg== Message-ID: <8c54ffbe-cace-e000-1212-f5b60aa030fc@bernhard-voelker.de> Date: Mon, 22 Oct 2018 22:18:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:X+Wopal69/XJJyxfPzgKhXOHRkdHk1rJICGhLzR/uU2GsBrn9vx vjPwY/+VPFD2c3/TykcXLqlhVT88wwQ37atCf8V4U1AIGuVhbQKRC6ZvO+vXxa+e+hyEZIW OnKOupSdUhHkYxCw3NFQx89S9whHqLqtI8s25ywpuSignUpttAjGz0RAjZml4sm2vN+JYnM FfDiUbmSCchhUqe2YFtpg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V01:K0:q3BB+OtvIew=:WcRifGBMSAzDlWO3lcD5O6 eAe0purFipwuTnzR4IRuC63FdAydqfaQCEGHqzuH4UpTBUvni5LNKLDeFygzlhJVI+3wg6dFX 3VkmVwOD/cY0ba+NK5HsDFBntobqFeGTEwdaGJUl0dKNyUFqi5HvygzKmD+r2/1i+P7MPd5HJ xIFVGtLebC+kjlvWN8IpxqLfykWhnf9StzNbCjj0emKLp8JzNKvNe5RCjnobgG8XZ7Mjtck+m I0HmXwlu9YdZDAzhwRE54VUdA5NChminszn/0KXpVn+QTcm1XaDb62e10l6Xo27WKQ2SQIZXD lSlTl50ZwTQe3DVfFHATSAwYNqBseT05zON3UOLe2m4GT/cQy6w95yPNw3hqE12KJWGVoIMwo GyggzK4pt7CzXVvF61I/Dq9Cx7IaC2FEFsn09ivqhWtKGef33gJ4UL01rJDQm1meGuc1Xljwx ES54DQ8KoZShKuIq4/w81O/SsAQEihQCWG7fTYJwl0og2ltb3wMn683xvUeNswvHRREvb0thy Xn6R6sEkYKACbGWzYJC0JNmyiECFtM6RTzhruwAlXkHfG6yrFHyGzj0gpKPJwU7rdnAt21xEQ xueuX3AD4tK3PkPtkyiiAa7q1bSdzQJtS5eWAaMcrAIx1FXYzFEfu2GV/QQmtUuGBpmA56YtY 3FnLQb7/yyP6gbfZTbLDEmTknr74OjQTBNgC1jOED8B+TG6p1ub2MSMi5PETlfcNkmI++yIjJ IxV3BE357F33zumH X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 33097 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 10/22/18 2:11 PM, Pádraig Brady wrote: > On 21/10/18 16:06, Bernhard Voelker wrote: >> On 10/21/18 2:09 AM, Paul Eggert wrote: >>> I have the opposite impression. Any scripts using this confusing -a operator are >>> already broken, and we should phase it out. Not that anybody actually *uses* >>> coreutils "test -a". >> >> Done with the attached 1st patch. >> >> The 2nd patch is a cleanup avoiding the redundant checking of unary operators >> in test_unop and unary_operator. >> >> The 3rd patch adds support for 'test -N FILE' as in bash. >> Please check (on various platforms / file systems if possible). > > Very nice. > atime has 24 hour resolution on vfat I think, > though I think your test should handle that. Thanks for the review - indeed, see: https://en.wikipedia.org/wiki/File_Allocation_Table#Directory_table Date resolution 2 seconds for last modified time, 10 ms for creation time, 1 day for access date, 2 seconds for deletion time Although I think it's unlikely that someone will dare to run the coreutils test-suite on vfat, I'd change the atime/mtime to set back in the test to 2 resp. 4 days: --- a/tests/misc/test-N.sh +++ b/tests/misc/test-N.sh @@ -24,13 +24,13 @@ touch file || framework_failure_ stat file returns_ 1 env test -N file || fail=1 -# Set access time to yesterday at noon: 'test -N' returns 0. -touch -a -d "12:00 today -1 days" file || framework_failure_ +# Set access time to 2 days ago: 'test -N' returns 0. +touch -a -d "12:00 today -2 days" file || framework_failure_ stat file env test -N file || fail=1 -# Set mtime to the day before yesterday: 'test -N' returns 1; -touch -m -d "12:00 today -2 days" file || framework_failure_ +# Set mtime to 2 days before atime: 'test -N' returns 1; +touch -m -d "12:00 today -4 days" file || framework_failure_ stat file returns_ 1 env test -N file || fail=1 > Also -N should work with common relatime mount option. What do you mean exactly? I mean, -N just reads what is stored in the file system, so there's nothing 'test' could do about it. Well, we could include a note to the texinfo page that -N heavily relies on the underlying file system and mount option. Thanks & have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 22 20:18:23 2018 Received: (at 33097) by debbugs.gnu.org; 23 Oct 2018 00:18:23 +0000 Received: from localhost ([127.0.0.1]:36532 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gEkOt-0008EP-3J for submit@debbugs.gnu.org; Mon, 22 Oct 2018 20:18:23 -0400 Received: from mail-pf1-f180.google.com ([209.85.210.180]:35645) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gEkOr-0008EC-Un for 33097@debbugs.gnu.org; Mon, 22 Oct 2018 20:18:22 -0400 Received: by mail-pf1-f180.google.com with SMTP id l17-v6so20732936pff.2 for <33097@debbugs.gnu.org>; Mon, 22 Oct 2018 17:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=cpkWsrpwAG9KCTQ1IJvb5bdQdPgTL8BPuFd2JvJRfD8=; b=W+nlXmcdF9f818fKRGlDhTUS5GS3afDrIVmrbv5crcrR/KhX34DDYIXNAPYSOqfsQw B6cBL1zgGAxtWCHEfeuxPmZbP2JDkKkSuYsLYy/nj+FzzEon37vX4SeoElYTEfOUY+94 7p2sDpgtHN/EZoqvHXV0a0p/nIXB/y2PNoFwZ7hJTW6lRTu2FAqUlmr/p5SbnbbL+2/K zJV8p96k3n9q3jeez1zZ7jAYYyXsgh72URpC96hzDEBdD4DnpmK/qVyAXT/I9QfjkxDb 8hPoW7Ag5GO41yxrEQ4QaeuCahaqxG9ekQk7O34toADYWQ+7SWw2G7k/cqWvFeLqq2BP c+DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=cpkWsrpwAG9KCTQ1IJvb5bdQdPgTL8BPuFd2JvJRfD8=; b=nqPWTG2Re8OFFliLvuZ+zwxAGfxPNXWaPzqXrjfxadUOyPys81rRtjfR+kzSHPgKw+ p91EPbaVB6Jrk8F3BBQg6GR1xddWBTxb8JeSZbPJJU46ngSpshidbSNmRIfi0i8NGd6f 24yW30m6MytflFebh3cAXW17CgfV3OHKA5iBt0Gd6FwkuxbpcsSuBAgQaj9MOCLB4sem XbAGRU0z8/o0pXuHEI3B4HKFARA8+hv9MqCT70EpRwnTy/jiUcDCzKgLxLDetTfi9FPf 32sDXucjV02IRUDCLGn2jrYd5OQG+IltOuFHxdN5AW3X0aLTfX0mmB78SAnQjvmyH00g 5MIA== X-Gm-Message-State: ABuFfogsmsLhqS1gLZchkGd3QchCeum6gMfOujAZP/SKyni+Vh0AQiR5 PdCAeggCF/i6SiVCZQMOh5I4/WTl X-Google-Smtp-Source: ACcGV62Am91iVkZXwx68hVctMPyhladdVmcRx6QFU/nk7Iwa1WhJ76f6VqTR3hujzOdNknO0LwY3DA== X-Received: by 2002:a65:5cc3:: with SMTP id b3-v6mr44891214pgt.277.1540253895272; Mon, 22 Oct 2018 17:18:15 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id f22-v6sm44064266pff.29.2018.10.22.17.18.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Oct 2018 17:18:13 -0700 (PDT) Subject: Re: bug#33097: test has filetest -a but man page doesn't list it To: Bernhard Voelker , Paul Eggert , Martin Schulte , 33097@debbugs.gnu.org References: <20181019224822.7994ce73bb7009249d7d2a14@schrader-schulte.de> <6153c275-fc83-35bb-bbff-377d75ba3b57@bernhard-voelker.de> <1edec5cf-be91-d3aa-dd0d-ffc6c999c08c@bernhard-voelker.de> From: Assaf Gordon Message-ID: Date: Mon, 22 Oct 2018 18:18:11 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1edec5cf-be91-d3aa-dd0d-ffc6c999c08c@bernhard-voelker.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 33097 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 21/10/18 05:06 PM, Bernhard Voelker wrote: > The 3rd patch adds support for 'test -N FILE' as in bash. > Please check (on various platforms / file systems if possible). "test-N.sh" passes on FreeBSD,OpenBSD,NetBSD (with their respective default file systems) and on cygwin 64bit over ntfs. Also passes on ext4 inside a directory with "chattr +A" (disabled access time). -assaf From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 26 07:58:54 2018 Received: (at 33097-done) by debbugs.gnu.org; 26 Oct 2018 11:58:54 +0000 Received: from localhost ([127.0.0.1]:43269 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gG0lR-0008Tr-0b for submit@debbugs.gnu.org; Fri, 26 Oct 2018 07:58:54 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:53983) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gG0lO-0008Te-Pe for 33097-done@debbugs.gnu.org; Fri, 26 Oct 2018 07:58:51 -0400 Received: from [10.0.2.15] ([62.153.148.194]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Miqvq-1fdfnv2fvo-00exX1; Fri, 26 Oct 2018 13:58:31 +0200 Received: from [10.0.2.15] ([62.153.148.194]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1Miqvq-1fdfnv2fvo-00exX1; Fri, 26 Oct 2018 13:58:31 +0200 Subject: Re: bug#33097: test has filetest -a but man page doesn't list it To: Assaf Gordon , Paul Eggert , Martin Schulte , 33097-done@debbugs.gnu.org References: <20181019224822.7994ce73bb7009249d7d2a14@schrader-schulte.de> <6153c275-fc83-35bb-bbff-377d75ba3b57@bernhard-voelker.de> <1edec5cf-be91-d3aa-dd0d-ffc6c999c08c@bernhard-voelker.de> From: Bernhard Voelker Message-ID: <149742ee-e6f5-63fd-357b-ec95a490bd6b@bernhard-voelker.de> Date: Fri, 26 Oct 2018 13:58:29 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: de-DE-1901 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:3nc4WL5Eu34wZvtGo0UXEQmiry9kB4xSFSi8pAfy9lDFaFY1c11 81AICamrCjsnUHY4fVFpKKKTTNYLNR23lz1ICsasQsZ2ol1vIlsbn56tXS6VGqQWVXNi+8N 6aeYXnqJXcgkHyI0+MMbyoF0x3K4iPXD2oSb69PtsMvOCmdfXZ5gx8hERTZ6xB2vjqcejkm WEYr4UdEEHviuTZ394pIg== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V01:K0:8o4n1wi6uAE=:oPz1loDMP7bCEOT79MmidT Z1s383AloOhjLPQvYYrrc62v6ZXOZqAyquv9tKf6h4Y9F1NjRXNCocOcRL/itZT+77A3i3dmR LX5l1nh+31iDYLbr5lCha8OedAxm4yr3aOst7EsEOziU3MwlWVkk4zbL40j8y6cP562/lLG2Q 9H8xmczFqRTVGwI5gDNdp+i5lDgNJZMR+thpen1tce+pmZsIGhy6N1w7UNCZ2zJm06auO5mLw 5bcvSWKkIrWHHrUrxlllZN0q6+eXQjEXi+hq8wI6E/K9xbO304VoEUgfV2IQds1WgSMerPap6 93r1q1EZxHki5iz7WblIZl3Q36OyKFCRb5hcnWy1TSUG8IPzNUVLAqKVldrTrmpfrD4dR/imZ 23iA70w4AenRgVLxGjsEFaiXgrK4UhJp5eXR69WOVvAZ3/KVL0/ZLudOv71WiOEj3Azxb1kCK 6mW6UElr68hv3vgWyY5A4gQS4pGnJEoADhZ+cjGyMe4NiG2g1pH/VlCTf+wzB48Kc7KJseg1g HelpdBykrGDTQ4C6p15Bi6IsrAqcORJ7T0q9XssTPVq7PAYxTrGmvg7PfWZ+DiIN4ELgXo/IQ xjdWcb5B4/q5M0rduHhyCszG23h5/HylMCka7JUvfE7FmBQJf2diGZJwNU53VZuPuLbGuGU0p EYixGVBYCmCJQSp1L3KREIQEZa7jn7vcMUa43/o1zwLEfZlHTiHboxdpdC1VqXdJgwusbBECC RCqFk9JXI0FDi56+ X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 33097-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 10/23/18 2:18 AM, Assaf Gordon wrote: > On 21/10/18 05:06 PM, Bernhard Voelker wrote: > >> The 3rd patch adds support for 'test -N FILE' as in bash. >> Please check (on various platforms / file systems if possible). > > "test-N.sh" passes on FreeBSD,OpenBSD,NetBSD (with their respective > default file systems) and on cygwin 64bit over ntfs. > > Also passes on ext4 inside a directory with "chattr +A" (disabled access time). Many thanks for the tests. It passes on SLES12 as well. Pushed with the change in 'test-N.sh' to +/-2 days for the vfat case. Marking this as done. Have a nice day, Berny From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 28 04:08:36 2018 Received: (at control) by debbugs.gnu.org; 28 Oct 2018 08:08:36 +0000 Received: from localhost ([127.0.0.1]:46595 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGg7f-0002xo-W2 for submit@debbugs.gnu.org; Sun, 28 Oct 2018 04:08:36 -0400 Received: from mail-it1-f179.google.com ([209.85.166.179]:51513) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGg7d-0002xT-L2; Sun, 28 Oct 2018 04:08:33 -0400 Received: by mail-it1-f179.google.com with SMTP id 74-v6so6115007itw.1; Sun, 28 Oct 2018 01:08:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:references:from:to:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=CROCjlhsaYI6zI1BKCeOkKoZkiPNnxznPx7+ivLrqBY=; b=RLI7jYWGuvI85KQiBHGx1DW/BWjunNLQXYqNPoa0XscBO3DQOY9+6BRtPGo9uYEcQH aDb8sWAUrO7WBvd+RDAaQI67VDa2cwB2gzmAoR7kiIFoyjqSE7OFm3NvpF5KGUhXXCEY 2XWtlD0icjmDy5SX3/pT3sKI7BRbkpifTijWfzn/MXnzNG8RF5c7HAg2de/k5efkV/cx 9PxDRo9h9AUFw1IDtVtMQm8CT43JPkAX4hcHFIn3FmcN6Suz/596VeUcwGSW7VWmRN0o wKH5LI8Gxh9xhJX32drx0cK8Rijy1iOneg+NkTo/NcqWxGWw82ue+ULp8K5QHQJN8mU6 0eYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:references:from:to:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=CROCjlhsaYI6zI1BKCeOkKoZkiPNnxznPx7+ivLrqBY=; b=tsHV8ZgKioVeUfhcZsIzekcCnfjOULwTbuz6vl3n8ZdWQqk+SjPszeRl3F6UqY1NN+ VfVhX7RXpPWw3g4KKlCpgrGlXnaJ6HDwude6aJlkFhQZ6mnv6lX+ix+s/Ta3ZkqW1Til uTzeML32rSk6GwuearMlP8f0WhqzlHkSLoXBJi9WkP3Elmxe5QOKWkKBB+IaAMk7RxKN QxzhVshLZ6lrxzOQ24iKHGt4OoFVVZtmN0aq5L0QRcVeXHQEX4+r4BGDBrlmtvmQXa7c 4t/ERORQ1f7WW8Sqldz1dPhVhDHYlfHmZ3OYRAC3iaBqCogcPReh2i35pCDEV2W/3FKf /Z+w== X-Gm-Message-State: AGRZ1gLjqYnvzrjudHZmflSkRIRLtlO/0sAqGO/emYn6yOaNtSyOzDsC 81xE1XxCRiOsJ7ICM+aX3uStogKS8wk= X-Google-Smtp-Source: AJdET5cWEgDyaedfvkZc1InvhGVniBQ5xijg+IIFydmdWPgSP8CWO1LyFOuITnw1nvdu73Wy424ZQg== X-Received: by 2002:a05:660c:247:: with SMTP id t7mr8557420itk.107.1540714107533; Sun, 28 Oct 2018 01:08:27 -0700 (PDT) Received: from tomato.housegordon.com (moose.housegordon.com. [184.68.105.38]) by smtp.googlemail.com with ESMTPSA id w124-v6sm5492918ita.0.2018.10.28.01.08.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Oct 2018 01:08:25 -0700 (PDT) Subject: Re: bug#15278: -a vs -e References: <20a64a55-04fe-4653-8b63-2091f9414f41@googlegroups.com> <5228B270.1080405@redhat.com> <5228B51B.7000905@redhat.com> From: Assaf Gordon To: 15278@debbugs.gnu.org Message-ID: <6d7daa3c-d8c7-0926-fb21-a26dc740a406@gmail.com> Date: Sun, 28 Oct 2018 02:08:24 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <5228B51B.7000905@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 15278 fixed forcemerge 33097 15278 close 15278 stop (triaging old bugs) On 2013-09-05 10:45 a.m., Eric Blake wrote: [...] > Coreutils therefore should fix its test to favor binary -a over unary > -a, when there are three arguments and the first is !. Just last week Bernhard committed test: remove support for the ambigous -a unary operator https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=88c32fa68ee7057744bfb6d41f6e8eb68801306f So closing this as "fixed". -assaf From unknown Sun Aug 17 00:59:17 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 25 Nov 2018 12:24:11 +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