Paul L. Snyder on 21 Apr 2010 11:39:29 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Shell scripting?

On Wed, 21 Apr 2010, Randall A Sindlinger wrote:

> On Wed, Apr 21, 2010 at 09:49:12AM -0400, Paul L. Snyder wrote:
> > 
> > Invoking bash as sh (that is, via the link) changes its behavior.
> > (It's the equivalent of invoking with the --posix option.)  It doesn't 
> > result in a perfect emulation of the historical Bourne shell behavior,
> > but it shifts a few things around so it's a bit closer.

> I never read the "INVOCATION" section of the bash man page before.
> I had no idea.  I can imagine an interview question now of "when
> is a symlink not just a symlink".  :-P

That is the design philosophy behind busybox...mash a bunch of utilities
into a single executable that changes its behavior depending on the name
by which it is invoked.

If you're writing a shell script and want to try something like this
yourself, the name the script was invoked under is stored in the $0

> After reading that section, either I'm misunderstanding it, or there's
> actually an even yet more subtle difference to invoking bash as /bin/sh
> vs invoking it with --posix.

You're right, my memory was fuzzy.  It also changes some other start-up
behaviors.  I'll leave the gory details to JP. ;)

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --