Bash scripting problems

Matthew Miller mattdm at mattdm.org
Sat Jan 8 21:45:21 UTC 2005


On Sat, Jan 08, 2005 at 05:39:58PM -0400, Jorge Fábregas wrote:
> On Saturday 08 January 2005 1:28 pm, Alexander Dalloz wrote:
> > sh != bash
> Hello there!
> I wouldn't say so :)  
> sh is actually a link to bash.
> ls -l /bin/sh
> lrwxrwxrwx  1 root root 4 Jul  2  2004 /bin/sh -> bash

Yes, but bash acts differently in that case:

       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
       interactive 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 execute 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.



-- 
Matthew Miller           mattdm at mattdm.org        <http://www.mattdm.org/>
Boston University Linux      ------>                <http://linux.bu.edu/>




More information about the fedora-list mailing list