Steven Lu
Steven Lu

Reputation: 43457

What is the purpose of the "where" builtin in zsh?

I found it impossible to google this, and couldn't find info in the man pages.

Upvotes: 2

Views: 212

Answers (3)

hek2mgl
hek2mgl

Reputation: 158080

The zsh builtins manual describes it:

where [ -wpms ] name ... Equivalent to whence -ca.

--

whence [ -vcwfpams ] name ... For each name, indicate how it would be interpreted if used as a command name.

-c Print the results in a csh-like format. This takes precedence over

-a Do a search for all occurrences of name throughout the command path. Normally only the first occurrence is printed. -v.

Upvotes: 2

rm4
rm4

Reputation: 721

From http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html:

where [ -wpms ] name ... Equivalent to whence -ca.

and:

whence [ -vcwfpams ] name ... For each name, indicate how it would be interpreted if used as a command name.

-v Produce a more verbose report.

-c Print the results in a csh-like format. This takes precedence over -v.

-w For each name, print ‘name: word’ where word is one of alias, builtin, command, function, hashed, reserved or none, according as name corresponds to an alias, a built-in command, an external command, a shell function, a command defined with the hash builtin, a reserved word, or is not recognised. This takes precedence over -v and -c.

-f Causes the contents of a shell function to be displayed, which would otherwise not happen unless the -c flag were used.

-p Do a path search for name even if it is an alias, reserved word, shell function or builtin.

-a Do a search for all occurrences of name throughout the command path. Normally only the first occurrence is printed.

-m The arguments are taken as patterns (should be quoted), and the information is displayed for each command matching one of these patterns.

-s If a pathname contains symlinks, print the symlink-free pathname as well.

Upvotes: 4

doublesharp
doublesharp

Reputation: 27637

According to the documented list of reserved words, where is not a keyword in bash.

https://www.gnu.org/software/bash/manual/html_node/Reserved-Word-Index.html

Upvotes: 0

Related Questions