On 11/11/05, Simon Geard <[EMAIL PROTECTED]> wrote:
> On Fri, 2005-11-11 at 13:26 +1000, David Lockwood wrote:
> > But /bin/sh is just a symlink to /bin/bash, the same binary runs. I
> > didn't think of this straight away because I knew bash was the only
> > shell I had installed, and I thought from my reading that "bash +
> > login = ~/.bash_profile gets read"
>
> Same binary, but a program can tell what name it's invoked by and alter
> it's behaviour accordingly. In the case of bash, invoking it as 'sh'
> causes it to run in a compatibility mode for classic Bourne shell, so it
> won't be running bash-specific login scripts.
I happened to be in the bash man page last night and found this tidbit:
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-
tive login shell, or a non-interactive shell with the --login option,
it first attempts to read and execute commands from /etc/profile and
~/.profile, in that order. The --noprofile option may be used to
inhibit this behavior. When invoked as an interactive shell with the
name sh, bash looks for the variable ENV, expands its value if it is
defined, and uses the expanded value as the name of a file to read and
execute. Since a shell invoked as sh does not attempt to read and exe-
cute commands from any other startup files, the --rcfile option has no
effect. A non-interactive shell invoked with the name sh does not
attempt to read any other startup files. When invoked as sh, bash
enters posix mode after the startup files are read.
So, there you go.
--
Dan
--
http://linuxfromscratch.org/mailman/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page