[Esd-l] 'Dropping the F' problem

Darryl Ross dross at syc.asn.au
Mon Feb 25 13:45:01 PST 2002


All,

Bash is smart enough to work out how it was called. An extract from the
bash man page says:

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.

Now, whether the start up files that are or are not read depending on how
it is called helps at all is a totally different matter. The point that I
am trying to make is that you can't assume something just because it is a
symlink to another program. It is easy enough to read $0 from a script and
set up some conditional statements based on that.

Solving problems is a process of elimination, despite what you may consider
to be 'logical' it is never a bad idea to eliminate all possibilities.

Darryl

-- 

Darryl Ross
Service to Youth Council Inc
dross at syc.asn.au


> On Sun, 24 Feb 2002, Simon Matthews wrote:
>
>> If it is not a silly question, why shoud that make any difference? On
>> Redhat Linux systems (and probably others) /bin/sh is a link to
>> /bin/bash.
>
> After some more thought about the problem I realized that my
> suggestion indeed wouldn't make any difference.
>
> --
> John Hardin KA7OHZ    ICQ#15735746    http://www.impsec.org/~jhardin/
> jhardin at impsec.org                       pgpk -a jhardin at wolfenet.com
>  768: 0x41EA94F5 - A3 0C 5B C2 EF 0D 2C E5  E9 BF C8 33 A7 A9 CE 76
> 1024: 0xB8732E79 - 2D8C 34F4 6411 F507 136C  AF76 D822 E6E6 B873 2E79
> -----------------------------------------------------------------------
>  In 1998 more than three times as many people in the US were killed by
>  incompetent physicians than were killed by handguns, yet the
>  President of the A.M.A. is adopting "gun safety" as his platform.
> -----------------------------------------------------------------------
>   981 days until the Presidential Election
> _______________________________________________
> Esd-l mailing list
> Esd-l at spconnect.com
> http://www.spconnect.com/mailman/listinfo/esd-l



More information about the esd-l mailing list