Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

MPW Command Reference


Which

Built-in

SYNTAX

Which [command] [-a] [-p]

DESCRIPTION

The Which command determines which file the MPW Shell executes when you enter the specified command. To do this, Which looks for commands defined by command aliases, built-in commands, and commands accessible through the {Commands} MPW Shell variable.

If you do not specify a command, the command writes to standard output all pathnames in the {Commands} variable, one pathname per line, in the order in which the MPW Shell searches for commands. In this case, -a and -p do not have any meaning.

INPUT

None

OUTPUT

Standard output. If command is a command alias, Which writes its definition to standard output; if it is a built-in command, Which echoes its name to standard output; if it is a tool, application, or script, Which writes its full pathname to standard output.

ALIAS RESOLUTION

This command resolves Finder aliases in pathnames specified in the Shell variable {Commands} when Which is searching for a command.

STATUS

Which can return the following status codes:

0

no errors

1

syntax error

2

command not found

3

any other error

PARAMETERS

command

Specifies the command.

OPTIONS

-a

Writes all paths to command to standard output. This option allows you to determine whether there are multiple commands with the same name.

-p

Writes progress information to diagnostic output as it searches each directory in {Commands}.

EXAMPLES

The command line

Which Asm

returns the pathname of the file that the MPW Shell executes when you enter Asm. For example, that command would return something like this:

HD:MPW:Tools:Asm

In the following example, executing the command line shows that there are three different MakeIt commands that the MPW Shell can execute, as determined by the current aliases and the {Commands} variable. When you enter MakeIt, the MPW Shell executes the first one found, which is the alias.

Which MakeIt -a
Alias MakeIt 'Make > tmp; tmp'
HD:MPW:Tools:MakeIt
HD:MPW:Scripts:MakeIt

Assuming that NewFolder is a built-in command, the command line

Which NewFolder

echoes the command name

NewFolder

 
 


Last Updated July 2000