On 15/03/2023 00:17, Chet Ramey wrote:
On 3/14/23 4:58 PM, Harald van Dijk wrote:
On 14/03/2023 20:41, Chet Ramey wrote:
On 3/12/23 10:19 PM, Harald van Dijk via austin-group-l at The Open Group wrote:

bash appears to disables the reading of .profile in POSIX mode entirely.

This isn't quite correct. By default, a login shell named `sh' or `-sh'
reads /etc/profile and ~/.profile. You can compile bash for `strict posix'
conformance, or invoke it with POSIXLY_CORRECT or POSIX_PEDANTIC in the
environment, and it won't.

Isn't it? The mode bash gets into when invoked as sh is described in the manpage (looking at the 5.2.15 manpage) as:

   If bash is invoked with the name sh, it tries to mimic the startup
   behavior of historical versions of sh as closely as possible, while
   conforming to the POSIX standard as well. [...] When invoked as sh,
   bash enters posix mode after the startup files are read.

The mode bash gets into when POSIXLY_CORRECT is set, the mode that can also be obtained with --posix, is described in the manpage as:

   When bash is started in posix mode, as with the --posix command line
   option, it follows the POSIX standard for startup files.

Right. When you force posix mode immediately, as I said above, bash won't
read the startup files. A login shell named sh or -sh reads the historical
startup fles, then enters posix mode.

We are clear on how bash behaves, I believe. What is not clear to me is how I should have worded my message so that you would not have taken issue with it. As far as I can tell, you are saying the same thing I was. I wrote that bash appears to disables the reading of .profile in POSIX mode entirely. It does. I do not see any contradiction between that and what you wrote: while a clarification that this does not apply to bash being invoked as sh or -sh is useful, I made no comment about what happens when bash is invoked as sh or -sh. My comment was about POSIX mode, and when invoked as sh or -sh, per the manpage and your own message, the startup file processing happens while bash is still in non-POSIX mode. So what should I have written instead? If I had written

  bash appears to disable the reading of .profile in POSIX mode (i.e.
  bash --posix) entirely.

would that have been sufficiently clear to avoid this discussion? If so I will keep that in mind.

Cheers,
Harald van Dijk

  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
    • Syntax ... Geoff Clare via austin-group-l at The Open Group
      • Re:... Harald van Dijk via austin-group-l at The Open Group
      • Re:... Robert Elz via austin-group-l at The Open Group
        • ... Harald van Dijk via austin-group-l at The Open Group
        • ... Robert Elz via austin-group-l at The Open Group
          • ... Harald van Dijk via austin-group-l at The Open Group
            • ... Chet Ramey via austin-group-l at The Open Group
              • ... Harald van Dijk via austin-group-l at The Open Group
              • ... Chet Ramey via austin-group-l at The Open Group
              • ... Harald van Dijk via austin-group-l at The Open Group
    • Re: Syn... Robert Elz via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group
  • [1003.1(2016... Austin Group Bug Tracker via austin-group-l at The Open Group

Reply via email to