Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
Shells: User's Guide: HP 9000 Computers > Chapter 23 Advanced Concepts and Commands

The whence Command

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

This is a command unique to the Korn Shell. When a name is provided to the whence command, it returns the way in which that name will be interpreted by the shell. The syntax is:

whence [-v ] name...

The flag, -v, produces a more verbose report.

When name is a reserved word, function or built-in command, the shell returns the command name. If the command has an alias, the alias is displayed. If neither of these is true, the full path name is printed. If name is not found, the shell so indicates.

$ whence -v type
type is an exported alias for whence -v

This example discovers that type is actually an exported alias for whence -v. So, just type:

type type
type is an exported alias for whence -v

The following example shows how the different commands are interpreted:

$ this() {
> print that
> }
$ whence while true alias this file fffile
while
:
alias
this
/usr/bin/file

$ whence -v while true alias this file fffile
while is a reserved word
true is an exported alias for :
alias is a shell builtin
this is a function
file is /usr/bin/file
fffile not found

The first part of this example defines a function this(), then asks whence to explain a series of six different words that might be used as commands.

The first five words of the set demonstrate the five types of command words the shell understands, and presents them in Korn Shell's precedence order. Notice in Table 23-1 “Precedence Order for Korn and POSIX Command Words” that POSIX Shell precedence is different from Korn Shell for function and built-in.

Table 23-1 Precedence Order for Korn and POSIX Command Words

Order

Korn Shell

POSIX Shell

1

reserved word

reservedword

2

alias

alias

3

built-in

function

4

function

built-in

5

other (e.g., path name)

other

 

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-1991 Hewlett-Packard Development Company, L.P.