Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14503
| Path | csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Stephane Chazelas <stephane.chazelas@gmail.com> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: "sh -a" sets the POSIXLY_CORRECT *environment* variable |
| Date | Wed, 15 Aug 2018 20:23:25 +0100 |
| Lines | 75 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.5153.1534361016.1292.bug-bash@gnu.org> (permalink) |
| References | <20180814155026.rr3f52t7six2frsv@chaz.gmail.com> <3fc90f34-c477-52c7-e56d-83a54c91fbee@case.edu> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| X-Trace | usenet.stanford.edu 1534361016 21609 208.118.235.17 (15 Aug 2018 19:23:36 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | bug-bash@gnu.org |
| To | Chet Ramey <chet.ramey@case.edu> |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=4DknAvdoiw0afal7rOlWLzdZf8bZEyvARHpkhrXUq6g=; b=S01aWG1U6STq4qaxRZ7l22zmaGYSrT+pe3UXhJVySuTdAnsii0SLbjUUeKjNplfOZy 0qEhRyakRcKHDXukv/O7iKm85V29ZXhdESf3X0l5K/wZIOFYk7NgGQe68ISzA9RRXl9D Qe7+qzvHA8dFltFH/6tdZVWeBkdZoHZTYrLH5r4kmBsx+ww0Z2HUau7yxvTU5Olc2yOk MXPjcJL26cwK6PjwIGw8Mamcp9YyaN+5XveSXenXz2nFW1Bon+DQOy//ccFA6cla9u/m Ntef2FVYwbca9CorqCrlqhHHl4+o/2tQhkJMripJ1GqTGCyNjKxx62md1AqitV2BAQiX wNKw== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=4DknAvdoiw0afal7rOlWLzdZf8bZEyvARHpkhrXUq6g=; b=F45O5A9yZWwu/760IqbT2hMpTXx5Ao/IHsp0gxSqecBLOE7dgPHXPtc1oelCghu7sV axNgpVkqiiIjYiawdNg4I4Db9tk0nezFFSxhh9LU4gAfD0ezFdlochtUv51+jK6MpfUX yQxA0oqscsxX2IA/HO2sgR6nTfRE7F/Z8CGBEA+a5305uBjBottuMO/kBX4K7++KRZGo Uo1cMr5nCafCBViRt/U16rJvS8r1T63Oe4Th1lSw1RsOfYxEfowszBnzczGqSRgAS9dl W56IHKYj/lWj9oKMc/yZ7ri7GzPMpslwVzGiWaK9Nq3gkmV/kFDxJ1YbBADYX3HwKDRJ vM7Q== |
| X-Gm-Message-State | AOUpUlFJIvN0xbKB79CYwNFbJ5c0orvKlwDTckQY22zaXpdqL+tutgi7 WN0B50D+CX8NCT7nyzxkwY0= |
| X-Google-Smtp-Source | AA+uWPwHksCDV8XkGZOP1weEPgMH89JDHJRA2JnERewkzr4gxCXPUGjfvkgzcZIVnbtp+jgMY/VtIQ== |
| X-Received | by 2002:adf:a907:: with SMTP id u7-v6mr18007931wrc.175.1534361007209; Wed, 15 Aug 2018 12:23:27 -0700 (PDT) |
| Content-Disposition | inline |
| In-Reply-To | <3fc90f34-c477-52c7-e56d-83a54c91fbee@case.edu> |
| User-Agent | NeoMutt/20171215 |
| X-detected-operating-system | by eggs.gnu.org: Genre and OS details not recognized. |
| X-Received-From | 2a00:1450:4864:20::436 |
| 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:14503 |
Show key headers only | View raw
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. The problem would show up mostly with #! /bin/sh -a scripts on systems where sh is bash, and where the script relies on non-POSIX behaviours of some GNU utilities. I can't see how that could be seen as a feature, I can't imagine anyone wanting that. If one wants to get a POSIX environment on a GNU system, they would do: export POSIXLY_CORRECT=y (and yes, it's good that bash does honour it) (and yes, it's not a very good interface as that means it can break scripts called within that environment and that rely on non-POSIX behaviour of some utilities, but that's beside the point being made here). If one wants a POSIX shell, they can use #! /bin/sh - Or: #! /usr/bin/env bash set -o posix if they can't rely on /bin/sh being a POSIX shell. But that should not affect the behaviour of all other utilities called within the script. Without "-a", it's OK as the $POSIXLY_CORRECT variable is not exported (it's not very useful that bash sets it (especially considering it's not documented), but at least it's harmless). -- Steohane
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: "sh -a" sets the POSIXLY_CORRECT *environment* variable Stephane Chazelas <stephane.chazelas@gmail.com> - 2018-08-15 20:23 +0100
csiph-web