Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Chet Ramey Newsgroups: gnu.bash.bug Subject: Re: "sh -a" sets the POSIXLY_CORRECT *environment* variable Date: Thu, 16 Aug 2018 10:33:06 -0400 Lines: 60 Approved: bug-bash@gnu.org Message-ID: References: <20180814155026.rr3f52t7six2frsv@chaz.gmail.com> <3fc90f34-c477-52c7-e56d-83a54c91fbee@case.edu> <20180815192324.24cvgmq7gnmds2ju@chaz.gmail.com> 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 1534429996 22970 208.118.235.17 (16 Aug 2018 14:33:16 GMT) X-Complaints-To: action@cs.stanford.edu Cc: chet.ramey@case.edu, bug-bash@gnu.org To: Stephane Chazelas Envelope-to: bug-bash@gnu.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1534429987; bh=wJBQpVFp7hmXwearkptKhucl3kKx4i6Ez1RVUmP0abA=; h=Reply-To:Cc:Subject:To:References:From:Message-ID:Date: MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=FWAKWjSnB09yd6Yr7iZkSwff1Z7YDsoxUFg6f5J/NwOfPK3CH+z9wqsQr5woqSP5a aG+qkMKShbzfpJC0rIP0LwBqPVl9+95CD2bgwps7JIeZQERjdCIqLR5gwBFlBNlzVK Sjz1rBFnXAlVDAV3mJHykO7N56PVP92af32o8Euy8mReFpVPvYWfuqfGe2TaqDzmD2 x9IJV2jUfNoPAeXuGICx4wqLmFZaXQtkLCxa26A9HaJznmLBFK272l3KI8gOlnl+6E XJ//C6WNHxPdyt3YA12mHAUABCm9tm5OJgWe3wLgenXyHWdRtXZUQCS1P7gnOJ7ILe qx1gTi2Jr9OXw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=case.edu; s=smtp-primary; t=1534429986; bh=RwNSdk8x9FOZrJkdx/XkSFMjDlB7rHRhLGSGrWDeqi8=; h=Reply-To:Cc:Subject:To:References:From:Message-ID:Date: MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=eUJLyTx/hwuD5UDy5pa140GNoitsjWG1rdPvJGQwwpekVNH5btedFQwmPhw/JOBup m/6PrttEldX2wCJ36lif0YjB1aRV0hHG/3KXTWwPCN8vfxkbiwOi7U+8s6xELPFvR3 oHazfQjvXcrLa9NfcXdx7ewDBlCLbaVyByd91cBBfXiyXvBE5Xo0pGRXV5TiqwJ1Yq p9qNl0IPkeU9EEy1IbDmo6ySwM5LcwylXIuhn/UzseJCGIFk9mGpSC7j5+OyyKTWWQ KPcXWGSRGetc/LF4OkKzHCXCZoZcsYirJ5SeFR5HwlDhESZS00XTNhiSJNo9Vk2Gjc ipJgyrGr29Vfw== 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/di50Gm1l1Na63d3RZ00SeFQos6WEwLUHEB0yp6KXluXLLIZitEJM0gQ2hldCBSYW1l eSA8Y2hldC5yYW1leUBjYXNlLmVkdT7CYQQTEQIAIQIbAwYLCQgHAwIDFQIDAxYCAQIeAQIX gAUCRX3FIgIZAQAKCRC7WGnwZOp0q069AKCNDRn+zzN/AHbaynls/Lvq1kH/RQCgkLvF8bDs maUHSxSIPqzlGuKWDxbOwE0EQQ6wbxAEAJCukwDigRDPhAuI+lf+6P64lWanIFOXIndqhvU1 3cDbQ/Wt5LwPzm2QTvd7F+fcHOgZ8KOFScbDpjJaRqwIybMTcIN0B2pBLX/C10W1aY+cUrXZ gXUGVISEMmpaP9v02auToo7XXVEHC+XLO9IU7/xaU98FL69l6/K4xeNSBRM/AAMHA/wNAmRB pcyK0+VggZ5esQaIP/LyolAm2qwcmrd3dZi+g24s7yjV0EUwvRP7xHRDQFgkAo6++QbuecU/ J90lxrVnQwucZmfz9zgWDkT/MpfB/CNRSKLFjhYq2yHmHWT6vEjw9Ry/hF6Pc0oh1a62USdf aKAiim0nVxxQmPmiRvtCmcJJBBgRAgAJBQJBDrBvAhsMAAoJELtYafBk6nSr43AAn2ZZFQg8 Gs/zUzvXMt7evaFqVTzcAJ0cHtKpP1i/4H4R9+OsYeQdxxWxTQ== User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 In-Reply-To: <20180815192324.24cvgmq7gnmds2ju@chaz.gmail.com> Content-Language: en-US X-Junkmail-Status: score=8/90, host=mpv2-2015.case.edu X-Junkmail-PrAS-Raw: score=8/90, refid=2.7.2:2018.8.16.135716:17:8.317, ip=, rules=DKIM_SIGNATURE, __HAS_REPLYTO, __HAS_CC_HDR, __MULTIPLE_RCPTS_CC_X2, __SUBJ_REPLY, __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __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_CC2, __REPLYTO_SAMEAS_FROM_DOMAIN, __ANY_URI, __HTTPS_URI, __URI_WITH_PATH, __URI_NO_WWW, __CP_URI_IN_BODY, __FRAUD_MONEY_CURRENCY_DOLLAR, __SUBJ_ALPHA_NEGATE, __MULTIPLE_URI_TEXT, __URI_IN_BODY, __URI_NOT_IMG, __FORWARDED_MSG, __NO_HTML_TAG_RAW, BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_2000_2999, __MIME_TEXT_P1, __MIME_TEXT_ONLY, __URI_NS, HTML_00_01, HTML_00_10, __FRAUD_MONEY_CURRENCY, BODY_SIZE_5000_LESS, [TRUNCATED], so=2010-03-03 19:42:08, dmn=2016-08-03-0138 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14504 On 8/15/18 3:23 PM, Stephane Chazelas wrote: > 2018-08-15 11:05:06 -0400, Chet Ramey: >> On 8/14/18 11:50 AM, Stephane Chazelas wrote: >>> Hi, >>> >>> This is from >>> https://unix.stackexchange.com/questions/462333/why-does-a-in-bin-sh-a-affect-sed-and-set-a-doesnt >>> (original investigation by Mark Plotnick) >>> >>> Though not documented, enabling the POSIX mode in bash whether >>> with >>> >>> - bash -o posix >>> - sh >>> - env SHELLOPTS=posix bash >>> - set -o posix # within bash >>> >>> causes it to set the value of the $POSIXLY_CORRECT shell >>> variable to "y" (if it was not already set) >> >> Yes. This behavior dates from early 1997. It was put in on request so users >> could get a posix environment from the shell, since GNU utilities >> understand the POSIXLY_CORRECT variable. I could improve the documentation >> there, but a 20-plus-year-old feature isn't going to change. > [...] > > Maybe there was a misunderstanding. > > It's fine that bash enters POSIX mode when $POSIXLY_CORRECT is > set. IOW, it's fine that bash enters POSIX mode when the users > request it. > > The problem I'm trying to raise is about the reverse behaviour: > that bash takes upon itself to request POSIX mode of all other > utilities when it itself enters POSIX mode, that it sets > $POSIXLY_CORRECT when it enters POSIX mode. You're commingling two separate issues. I explained the first one yesterday: that bash, back in 1997, added setting POSIXLY_CORRECT when turning on Posix mode as the result of requests to support the `standard' GNU mechanism for indicating POSIX behavior. This, in itself, is benign: it still requires that a user export the variable for utilities to inherit whatever POSIX-specific behavior they implement. This is a `problem' only when you combine it with the other issue: the rarely-used `allexport' option and which variables get auto-exported. I haven't weighed in on that one, but I am inclined to say that allexport covers all the variables a shell sets internally, whether ones like POSIXLY_CORRECT or IGNOREEOF that indicate settings, or ones that are set as side effects of builtins like `read' and `getopts'. -- ``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/