Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14725
| Path | csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Chet Ramey <chet.ramey@case.edu> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: Strange (wrong?) behaviour of "test ! -a file" |
| Date | Sun, 21 Oct 2018 13:03:06 -0400 |
| Organization | ITS, Case Western Reserve University |
| Lines | 48 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.2548.1540141403.1284.bug-bash@gnu.org> (permalink) |
| References | <20181021113211.23c6b725374a558e83bf6718@schrader-schulte.de> |
| Reply-To | chet.ramey@case.edu |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | usenet.stanford.edu 1540141404 27483 208.118.235.17 (21 Oct 2018 17:03:24 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | chet.ramey@case.edu |
| To | Martin Schulte <gnu@schrader-schulte.de>, bug-bash@gnu.org |
| Envelope-to | bug-bash@gnu.org |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:cc:subject:to:references:from:openpgp :autocrypt:organization:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=UwoTf3dhqP0O2JzBrmhVHbea527AsL93BoU3MerqRZA=; b=tyaasOUsa6XGbyA1eUbhHfjB3Nak3SSwtZxLqZkbXd5XvJbem1bolOxSqvRTJSCujT ejW+qsNWMbx78E0fsjICSDMZsZm4R/QOa6ZQ2EybiIace0IllKZRlwUvw4XCX/xN2Un4 16x9hktPkuAjxwIBYnf7hBfqzHF986B8KR3mulnSjsw/ELUbJTe6NatOWTu9VIUUtPOk x7s+fTTA3BxdE0ytdPJ7db3ggCiANHkM9nhwrqa5Oqx0Z1uCQD/ovV6LGCJrDy81fKfZ Uq3xPd86G9C1Gri6s+gdab5lqjFqK0uwSxM/IbToq61RqfFD7kOqZufPTrCufIflHjSY DY3w== |
| X-Gm-Message-State | ABuFfoiIaAo1u1pQkvz0txlBsiilOFFvf3TfoNk3JoqKXQamqJxq9bKp o7xwkCQMVhVUnYJ4m0/RW+1LCN4gJ2IOkMDWZMjbq7YfnF+u0ezIZZWC/DnThu8I1avQZ75ShKt P2RNXorvPXYs= |
| X-Received | by 2002:a37:b042:: with SMTP id z63-v6mr39409072qke.94.1540141389050; Sun, 21 Oct 2018 10:03:09 -0700 (PDT) |
| X-Google-Smtp-Source | ACcGV61ESpXylFAC8p3sbXWfJ7WF+866TYlVoZldC5B29hBMFUKR3rgscTulPUbRsyrzfs/yvRfTzw== |
| X-Received | by 2002:a37:b042:: with SMTP id z63-v6mr39409058qke.94.1540141388806; Sun, 21 Oct 2018 10:03:08 -0700 (PDT) |
| Openpgp | preference=signencrypt |
| Autocrypt | addr=chet.ramey@case.edu; prefer-encrypt=mutual; keydata= xsDiBEEOsGwRBACFa0A1oa71HSZLWxAx0svXzhOZNQZOzqHmSuGOG92jIpQpr8DpvgRh40Yp AwdcXb8QG1J5yGAKeevNE1zCFaA725vGSdHUyypHouV0xoWwukYO6qlyyX+2BZU+okBUqoWQ koWxiYaCSfzB2Ln7pmdys1fJhcgBKf3VjWCjd2XJTwCgoFJOwyBFJdugjfwjSoRSwDOIMf0D /iQKqlWhIO1LGpMrGX0il0/x4zj0NAcSwAk7LaPZbN4UPjn5pqGEHBlf1+xDDQCkAoZ/VqES GZragl4VqJfxBr29Ag0UDvNbUbXoxQsARdero1M8GiAIRc50hj7HXFoERwenbNDJL86GPLAQ OTGOCa4W2o29nFfFjQrsrrYHzVtyA/9oyKvTeEMJ7NA3VJdWcmn7gOu0FxEmSNhSoV1T4vP2 1Wf7f5niCCRKQLNyUy0wEApQi4tSysdz+AbgAc0b/bHYVzIf2uO2lIEZQNNt+3g2bmXgloWm W5fsm/di50Gm1l1Na63d3RZ00SeFQos6WEwLUHEB0yp6KXluXLLIZitEJM0aQ2hldCBSYW1l eSA8Y2hldEBjd3J1LmVkdT7CYQQTEQIAIQIbAwYLCQgHAwIDFQIDAxYCAQIeAQIXgAUCQ+La kQIZAQAKCRC7WGnwZOp0q9rGAJ4sRGLmlF8klZTH75z7jyQScpU6aACeNMahjWIhumt4u96d 9mdMJqlabVnOwE0EQQ6wbxAEAJCukwDigRDPhAuI+lf+6P64lWanIFOXIndqhvU13cDbQ/Wt 5LwPzm2QTvd7F+fcHOgZ8KOFScbDpjJaRqwIybMTcIN0B2pBLX/C10W1aY+cUrXZgXUGVISE MmpaP9v02auToo7XXVEHC+XLO9IU7/xaU98FL69l6/K4xeNSBRM/AAMHA/wNAmRBpcyK0+Vg gZ5esQaIP/LyolAm2qwcmrd3dZi+g24s7yjV0EUwvRP7xHRDQFgkAo6++QbuecU/J90lxrVn QwucZmfz9zgWDkT/MpfB/CNRSKLFjhYq2yHmHWT6vEjw9Ry/hF6Pc0oh1a62USdfaKAiim0n VxxQmPmiRvtCmcJJBBgRAgAJBQJBDrBvAhsMAAoJELtYafBk6nSr43AAn2ZZFQg8Gs/zUzvX Mt7evaFqVTzcAJ0cHtKpP1i/4H4R9+OsYeQdxxWxTQ== |
| User-Agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 |
| In-Reply-To | <20181021113211.23c6b725374a558e83bf6718@schrader-schulte.de> |
| Content-Language | en-US |
| X-Junkmail-Status | score=7/90, host=mpv2-2015.case.edu |
| X-Junkmail-PrAS-Raw | score=7/90, refid=2.7.2:2018.10.21.155415:17:7.944, ip=, rules=__YOUTUBE_RCVD, __X_GOOGLE_DKIM_SIGNATURE, __HAS_REPLYTO, __HAS_CC_HDR, __SUBJ_REPLY, __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT, __TO_MALFORMED_2, __TO_NAME, __TO_NAME_DIFF_FROM_ACC, __REFERENCES, __HAS_FROM, FROM_EDU_TLD, __HAS_MSGID, __SANE_MSGID, DATE_TZ_NA, __USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION, __IN_REP_TO, __CT, __CT_TEXT_PLAIN, __CTE, __REPLYTO_SAMEAS_FROM_ADDY, __REPLYTO_SAMEAS_FROM_ACC, __FROM_DOMAIN_IN_ANY_CC1, __FROM_DOMAIN_IN_ANY_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __URI_WITH_PATH, __URI_NO_WWW, __CP_URI_IN_BODY, __C230066_P5, __SUBJ_ALPHA_NEGATE, __MULTIPLE_URI_TEXT, __URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG, __NO_HTML_TAG_RAW, BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_1800_1899, __MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS, IN_REP_TO, MSG_THREAD, [TRUNCATED], so=2010-03-03 19:42:08, dmn=2016-08-03-0138 |
| X-Mirapoint-Virus-RAPID-Raw | score=unknown(0), refid=str=0001.0A020205.5BCCB14E.0041,ss=1,re=0.000,fgs=0, ip=174.131.57.47, so=2016-11-06 16:00:04, dmn=2011-05-27 18:58:46 |
| X-Mirapoint-Loop-Id | 89eac3b0cd4fe5a01559eda56a0b33fa |
| X-detected-operating-system | by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] |
| X-Received-From | 129.22.103.227 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org> |
| List-Unsubscribe | <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe> |
| List-Archive | <http://lists.gnu.org/archive/html/bug-bash/> |
| List-Post | <mailto:bug-bash@gnu.org> |
| List-Help | <mailto:bug-bash-request@gnu.org?subject=help> |
| List-Subscribe | <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe> |
| Xref | csiph.com gnu.bash.bug:14725 |
Show key headers only | View raw
On 10/21/18 5:32 AM, Martin Schulte wrote:
> Hello,
>
> "help test" states that "-a file" and "-e file" do them same ("True if
> file exists.")
>
> This is not true when negating the result as you can see from the output
> below. The bash builtin even behaves different than the test from
> coreutils.
This is documented behavior consistent with the POSIX standard. It's been
this way for so long, there is even a question in the long-dormant FAQ
about it (E1).
The `test' command's behavior is determined by the number of arguments,
as specified by POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html#tag_20_128
The help text for test says
"The behavior of test depends on the number of arguments. Read the
bash manual page for the complete specification."
The man page says:
3 arguments
The following conditions are applied in the order listed.
If the second argument is one of the binary conditional
operators listed above under CONDITIONAL EXPRESSIONS, the
result of the expression is the result of the binary test
using the first and third arguments as operands. The -a
and -o operators are considered binary operators when
there are three arguments.
This is the order in which the POSIX algorithm specifies the conditions.
> It looks as if "! -a file" results in "( ! ) -a ( file )" in bash while
> it results in "! ( -a file )" in coreutils' test.
Coreutils does the tests in a different order than they appear in the POSIX
standard.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: Strange (wrong?) behaviour of "test ! -a file" Chet Ramey <chet.ramey@case.edu> - 2018-10-21 13:03 -0400
csiph-web