[sf-lug] bash ... and POSIX?

Michael Paoli Michael.Paoli at cal.berkeley.edu
Tue Aug 9 08:13:34 PDT 2016


How bash is invoked - including the basename of arg0,
and environment, also impact how POSIX compliant bash
attempts to behave.

E.g.:
$ bash -c 'set -o' | fgrep posix
posix           off
$ ln -s /bin/bash sh
$ ls -no sh
lrwxrwxrwx 1 1003 9 Aug  9 08:00 sh -> /bin/bash
$ ./sh -c 'set -o' | fgrep posix
posix           on
$

"
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 an  interac-
"

"
POSIXLY_CORRECT
        If this variable is in the environment  when  bash  starts,  the
        shell  enters posix mode before reading the startup files, as if
        the --posix invocation option had been supplied.  If it  is  set
        while  the  shell is running, bash enables posix mode, as if the
        command set -o posix had been executed.
"

references, excerpts, and more trivia:
bash(1)
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
http://wiki.wlug.org.nz/POSIX_ME_HARDER

> From: "Rick Moen" <rick at linuxmafia.com>
> Subject: Re: [sf-lug] BASH vs DASH to SH vs DASH ?
> Date: Tue, 9 Aug 2016 00:56:02 -0700

> bash supports a --posix command-line option that forces it to be
> _closer_ than it normally is to POSIX-compliance, but even that is not
> entirely POSIX-compliant.  Not that most people care.





More information about the sf-lug mailing list