OSDN Git Service

73d57f63b654eebad7c505055650eec4e35762d6
[linuxjm/jm.git] / info / GNU_which / original / which.info
1 This is which.info, produced by makeinfo version 5.2 from which.texi.
2
3 INFO-DIR-SECTION System administration
4 START-INFO-DIR-ENTRY
5 * Which: (which).                               Show full path of commands.
6 END-INFO-DIR-ENTRY
7
8
9 This file documents 'which' version 2.x.
10
11 Copyright (C) 2000 - 2015, by
12
13 Carlo Wood, Run on IRC <carlo@alinoe.com>
14 RSA-1024 0x624ACAD5 1997-01-26                    Sign & Encrypt
15 Fingerprint16 = 32 EC A7 B6 AC DB 65 A6  F6 F6 55 DD 1C DC FF 61
16
17 Permission is granted to make and distribute verbatim copies of
18 this manual provided the copyright notice and this permission notice
19 are preserved on all copies.
20
21 \1f
22 File: which.info,  Node: Top,  Next: Which Program,  Prev: (dir),  Up: (dir)
23
24 'which': Show the full path of commands
25 ***************************************
26
27 The 'which' program shows the full path of (shell) commands.
28
29 This file documents 'which' version 2.21, updated 20 March 2015.
30
31 * Menu:
32
33 * Which Program::               The 'which' Program
34 * Invoking Which::              How to invoke 'which'
35 * Option Summary::              Overview of commandline options
36 * Return Value::                The return value of 'which'
37 * Example::                     Examples of invokation
38 * Bugs::                        Known bugs
39 * See Also::                    Related UNIX commands
40 * Index::                       Index
41
42 \1f
43 File: which.info,  Node: Which Program,  Next: Invoking Which,  Prev: Top,  Up: Top
44
45 1 The 'which' Program
46 *********************
47
48 'Which' takes one or more arguments.  For each of its arguments it
49 prints to stdout the full path of the executables that would have been
50 executed when this argument had been entered at the shell prompt.  It
51 does this by searching for an executable or script in the directories
52 listed in the environment variable 'PATH' using the same algorithm as
53 'bash(1)'.
54
55 \1f
56 File: which.info,  Node: Invoking Which,  Next: Option Summary,  Prev: Which Program,  Up: Top
57
58 2 Invoking 'which'
59 ******************
60
61 The synopsis to invoke 'which' is
62
63      which [options] [--] programname [...]
64
65 * Menu:
66
67 * Option Summary::        Option summary
68
69 \1f
70 File: which.info,  Node: Option Summary,  Next: Return Value,  Prev: Invoking Which,  Up: Top
71
72 3 Option Summary
73 ****************
74
75 '--all'
76 '-a'
77      Print all matching executables in 'PATH', not just the first.
78
79 '--read-alias'
80 '-i'
81      Read aliases from stdin, reporting matching ones on stdout.  This
82      is useful in combination with using an alias for which itself.  For
83      example
84      'alias which='alias | which -i''.
85
86 '--skip-alias'
87      Ignore option '--read-alias', if any.  This is useful to explicity
88      search for normal binaries, while using the '--read-alias' option
89      in an alias or function for which.
90
91 '--read-functions'
92      Read shell function definitions from stdin, reporting matching ones
93      on stdout.  This is useful in combination with using a shell
94      function for which itself.  For example:
95      'which() { declare -f | which --read-functions $@ }
96      export -f which'
97
98 '--skip-functions'
99      Ignore option '--read-functions', if any.  This is useful to
100      explicity search for normal binaries, while using the
101      '--read-functions' option in an alias or function for which.
102
103 '--skip-dot'
104      Skip directories in 'PATH' that start with a dot.
105
106 '--skip-tilde'
107      Skip directories in 'PATH' that start with a tilde and executables
108      which reside in the 'HOME' directory.
109
110 '--show-dot'
111      If a directory in 'PATH' starts with a dot and a matching
112      executable was found for that path, then print "./programname"
113      rather than the full path.
114
115 '--show-tilde'
116      Output a tilde when a directory matches the 'HOME' directory.  This
117      option is ignored when which is invoked as root.
118
119 '--tty-only'
120      Stop processing options on the right if not on tty.
121
122 '--version, -v, -V'
123      Print version information on standard output then exit
124      successfully.
125
126 '--help'
127      Print usage information on standard output then exit successfully.
128
129 \1f
130 File: which.info,  Node: Return Value,  Next: Example,  Prev: Option Summary,  Up: Top
131
132 4 Return Value
133 **************
134
135 'Which' returns the number of failed arguments, or -1 when no
136 'programname' was given.
137
138 \1f
139 File: which.info,  Node: Example,  Next: Bugs,  Prev: Return Value,  Up: Top
140
141 5 Example
142 *********
143
144 The recommended way to use this utility is by adding an alias (C shell)
145 or shell function (Bourne shell) for 'which' like the following:
146
147    [ba]sh:
148
149      which ()
150      {
151        (alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@
152      }
153      export -f which
154
155    [t]csh:
156
157      alias which 'alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
158
159 This will print the readable ~/ and ./ when starting which from your
160 prompt, while still printing the full path when used from a script:
161
162      > which q2
163      ~/bin/q2
164      > echo `which q2`
165      /home/carlo/bin/q2
166
167 \1f
168 File: which.info,  Node: Bugs,  Next: See Also,  Prev: Example,  Up: Top
169
170 6 Bugs
171 ******
172
173 The 'HOME' directory is determined by looking for the 'HOME' environment
174 variable, which aborts when this variable doesn't exist.  'Which' will
175 consider two equivalent directories to be different when one of them
176 contains a path with a symbolic link.
177
178 \1f
179 File: which.info,  Node: See Also,  Next: Index,  Prev: Bugs,  Up: Top
180
181 7 See Also
182 **********
183
184 'bash(1)'
185
186 \1f
187 File: which.info,  Node: Index,  Prev: See Also,  Up: Top
188
189 Index
190 *****
191
192 \0\b[index\0\b]
193 * Menu:
194
195 * '--all':                               Option Summary.       (line  6)
196 * '--help':                              Option Summary.       (line 57)
197 * '--read-alias':                        Option Summary.       (line 10)
198 * '--read-functions':                    Option Summary.       (line 22)
199 * '--show-dot':                          Option Summary.       (line 41)
200 * '--show-tilde':                        Option Summary.       (line 46)
201 * '--skip-alias':                        Option Summary.       (line 17)
202 * '--skip-dot':                          Option Summary.       (line 34)
203 * '--skip-functions':                    Option Summary.       (line 29)
204 * '--skip-tilde':                        Option Summary.       (line 37)
205 * '--tty-only':                          Option Summary.       (line 50)
206 * '--version':                           Option Summary.       (line 53)
207 * '-a':                                  Option Summary.       (line  6)
208 * '-i':                                  Option Summary.       (line 10)
209 * '-v':                                  Option Summary.       (line 53)
210 * '-V':                                  Option Summary.       (line 53)
211 * aliases, handling of:                  Example.              (line  6)
212 * Bugs, known:                           Bugs.                 (line  6)
213 * Command line Options:                  Option Summary.       (line  6)
214 * Description of 'which':                Which Program.        (line  6)
215 * Examples:                              Example.              (line  6)
216 * Invoking 'which':                      Invoking Which.       (line  6)
217 * Options, command line:                 Option Summary.       (line  6)
218 * Overview of command line options:      Option Summary.       (line  6)
219 * Return value of 'which':               Return Value.         (line  6)
220 * Synopsis:                              Invoking Which.       (line  6)
221
222
223 \1f
224 Tag Table:
225 Node: Top\7f637
226 Node: Which Program\7f1286
227 Node: Invoking Which\7f1778
228 Node: Option Summary\7f2046
229 Node: Return Value\7f3943
230 Node: Example\7f4152
231 Node: Bugs\7f4884
232 Node: See Also\7f5227
233 Node: Index\7f5335
234 \1f
235 End Tag Table