Operating System - HP-UX
1833187 Members
3159 Online
110051 Solutions
New Discussion

what's the difference of 'which' and' whence'?

 
SOLVED
Go to solution
常有慈悲心
Regular Advisor

what's the difference of 'which' and' whence'?

i find whence is a built-in shell command,
is it not product a new subprocess ,
while which produce a new subprocess ,because
'which' is a os command?
4 REPLIES 4
Sridhar Bhaskarla
Honored Contributor
Solution

Re: what's the difference of 'which' and' whence'?

Hi,

Yes. 'Whence' is built-in command to Korn Shell and can recognize aliases in addition. "which" is a command and runs as a seperate process.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
Franky_1
Respected Contributor

Re: what's the difference of 'which' and' whence'?

Hi,

whence is a shell built-in and is normally set as alias for type (whence -v)

which is a process (/usr/bin/which)

Because there's no manual for whence you can find some hints looking for man sh-posix
and then searching for whence

Regards

Franky
Don't worry be happy
Muthukumar_5
Honored Contributor

Re: what's the difference of 'which' and' whence'?

whence is a built-in binary with korn shell. It is used to search a shell function name, alias name, or keyword

which is a system binary used to locate system's routines or binaries location by searching PATH locations.

Both of the binaries are using to search shell environment variable PATH.

By default, built-in binaries associated with shells will not fork a sub-process. But which is not related to shell so it will fork a new process.
Easy to suggest when don't know about the problem!
Geoff Wild
Honored Contributor

Re: what's the difference of 'which' and' whence'?

From man:

whence - locate a command and describe its type
Without -v, whence writes on standard output an absolute pathname, if any, corresponding to name based on the complete search order that the shell uses. If name not found, then no output is produced.

If -v is specified, the output will also contain information that indicates how the given name would be interpretted by the shell in the current execution environment.

whence (AT&T Labs Research) 1999-07-07
author
David Korn


which - locate a program file including aliases and paths For each name given, which searches for the file that would be executed if name were given as a command, and displays the absolute path of that file. Each argument is expanded if it is aliased, and searched for along the user's path. Both aliases and path are determined by sourcing (executing) the user's .cshrc file.

which was developed by the University of California, Berkeley.


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.