bug-bash
[Top][All Lists]
Advanced

[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: Matthew Woehlke
Subject: Re: GNU bash, 3.00.15(1)-release, referenced cmd in cwd executes alternate cmd
Date: Thu, 04 Jan 2007 10:21:43 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.9) Gecko/20061206 Thunderbird/1.5.0.9 Mnenhy/0.7.4.0

Bob Proulx wrote:
Bojan Land wrote:
Do you know which shells do not have type and thus rely on which?

I wouldn't guess that *any* shell "relies" on 'which'... probably all shells have built-in $PATH lookup, but may not expose it to the user in the way bash's 'type' does.

As far as I know there is no portable way to get this information.  It
is impossible to determine this information portably without writing a
portable shell script and including it in the application needing this
information.

Right; if you need the output of 'type', the safest way I know of is to roll your own function in portable shell script.

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'.
XSI extensions to POSIX require 'command -v'.  Debian implemented
'which' as a bash shell script and fixed problems with the csh
implementation making the Debian 'which' usable but different from
everyone else's 'which' command.

And newer GNU systems have GNU which; a stand-alone program that does neat things like read aliases from stdin so that you can do:
$ which ll
alias ll='ls -l --color=tty'
        /usr/local/bin/ls
$ alias which
alias which='alias | which -i'
$ which --version
GNU which v2.16, Copyright (C) 1999 - 2003 Carlo Wood.
[snip]

--
Matthew
Caution: keep out of reach of adults.





reply via email to

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