[Top][All Lists]

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

Re: GNU bash, 3.00.15(1)-release, referenced cmd in cwd executes alterna

From: Bob Proulx
Subject: Re: GNU bash, 3.00.15(1)-release, referenced cmd in cwd executes alternate cmd
Date: Thu, 4 Jan 2007 11:31:23 -0700
User-agent: Mutt/1.5.9i

Bojan Land wrote:
> Bob Proulx wrote:
> > This is possible when it has been cached by bash and then the
> > executable is either moved from its original location or a new
> > executable appears earlier in PATH.
> I did not move the executable.

Right.  "or a new executable appears earlier in PATH."  I believe that
after invoking the /usr/bin/ version you created a new executable by
the same name earlier in PATH.

> If I just use 'type mycmd' the result is similar in that it simply
> prepends the query before the result with " is " inbetween; -p prevents
> this additional processing and output?

-p only prints a path if the result is a file and has a path to print.

> One clarification I need is for these results:
> > $ type help
> > help is a shell builtin
> > $ type -p help
> > $ type -t help
> > builtin
> > $
> Why is there no output for -p?

There is no path for type -p help because help is a shell builtin and
does not have a path.  It does not exist on the filesystem.  It
exists only inside the shell as a builtin command.

> I had never thus far ran the help builtin, ever!
> I think I just found a new favorite command!  Many thanks!

Something for the future then.

> > $ type which
> > which is aliased to `alias | /usr/bin/which --tty-only --read-alias 
> > --show-dot --show-tilde'
> > $ type -p which
> > $ type -t which
> > alias
> > $
> I was expecting the result of -p to be:
> which is an alias
> or even:
> which is /usr/bin/which (aliased)

Asking for the path would only print a path if it has a path to
print.  Since aliases do not have paths nothing is printed.

> Before I compare every shell I can find possibly duplicating the work
> that someone else must have already done in all the years unii have been
> around, can you suggest a good place to start for this information
> beyond the typical websearch of "unix shell comparison"?

Perhaps someone else on the list will have a good suggestion.

> Are sh and POSIX shell two different shells?

Today they are the same.  In old legacy systems /bin/sh was the Bourne
shell.  The Bourne shell predates the POSIX shell and is different.
The Bourne shell does not have aliases or functions for example.  But
all modern systems have /bin/sh as the POSIX shell.  (And before
someone pipes in that Solaris /bin/sh is still the Bourne shell and
that you need /usr/xpg4/bin/sh to get the POSIX shell let me say
again, all *modern* systems have /bin/sh as the POSIX shell.)

> > Traditional Unix machines used a csh script /usr/bin/which to search a
> > defined set of system paths.  Newer ksh used 'whence'.  
> > Bash uses 'type'.
> Is whence just an alias for which or a different approach?

Almost.  In ksh whence is a builtin command the same as that in bash
type is a builtin command.

> Seems there are three commands returning same results differently
> encapsulated.  Is there a purpose to having command, which and type on a
> system or can one of them do the job of the other two?

Ask five people the same question and you will get seven different
answers!  These are different implementations by different people.
Not having a standard in this area meant that there are no standards.
They chose differently from each other.

> The results did not say hashed and I've tried it several times.  The
> only way I can get type to report hashed is by using hash manually:

Probably version of shell differences.  I don't know.

> Is tracking the logical path only useful for simplicity and user
> interface reasons?

Yes.  Although I disagree with simplicity.  But it is there because
users wanted it.

> Being able to cd but not ls is like walking through a dark room without
> any senses.  I thought by setting +P prior to re-entering
> html_users/user I would return to /home/user/public_html however that's
> not the case.

That would be the -P setting.

> No bashref from info, however there are html and ps versions.

Well, that is probably a systems bug then.  You might wish to file a
bug report to whoever installed your system.

> I'm always amazed when I find many ways to see the same result, such as
> man and info, however info and man return drastically different
> documentation for info itself!  It's as if my system has duplication of
> documentation - is this useful somehow?

I am not going to open that Pandora's box.

> You seem like someone who's administered many lists for a long time!
> I've learned a lot just from these few emails, many thanks once again!

I learn something new every day from people who post on the mailing
lists.  The community of people working to improve free software is an
unmatched strength.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]