OSDN Git Service

72e87292d88e249eed5ce7d1292a4edc631b4f06
[linuxjm/jm.git] / info / GNU_which / draft / texi / which.texi
1 \input texinfo-ja   @c -*-texinfo-*-
2 @c ===========================================================================
3 @c
4 @c This file was generated with po4a. Translate the source file.
5 @c
6 @c ===========================================================================
7
8 @c %**start of header
9 @setfilename which.info
10 @documentencoding UTF-8
11 @documentlanguage ja
12 @settitle @command{which}: コマンドのフルパス表示
13 @include version.texi
14 @dircategory System administration
15 @direntry
16 * Which: (which).            コマンドのフルパスを表示
17 @end direntry
18 @c %**end of header
19
20 @setchapternewpage odd
21
22 @ifinfo
23 @format
24
25 @c !BEGIN INTRO
26 @c !END INTRO
27 このファイルは `which' version 2.x@ を説明するものです。
28
29 @c !BEGIN COPYING
30 Copyright @copyright{} 2000 - 2015, by
31
32 Carlo Wood, Run on IRC <carlo@@alinoe.com>
33 RSA-1024 0x624ACAD5 1997-01-26                    Sign & Encrypt
34 Fingerprint16 = 32 EC A7 B6 AC DB 65 A6  F6 F6 55 DD 1C DC FF 61
35
36 Permission is granted to make and distribute verbatim copies of
37 this manual provided the copyright notice and this permission notice
38 are preserved on all copies.
39 @end format
40
41 @ignore
42 Permission is granted to copy and distribute modified versions of this
43 manual under the conditions for verbatim copying, provided also that the
44 section entitled ``GNU General Public License'' is included exactly as
45 in the original, and provided that the entire resulting derived work is
46 distributed under the terms of a permission notice identical to this
47 one.
48
49 Permission is granted to copy and distribute translations of this manual
50 into another language, under the above conditions for modified versions,
51 except that the section entitled ``GNU General Public License'' may be
52 included in a translation approved by the author instead of in the
53 original English.
54 @end ignore
55 @c !END COPYING
56 @end ifinfo
57
58 @titlepage
59 @title Which
60 @subtitle コマンドのフルパス表示
61 @sp 1
62 @subtitle 編集版 @value{EDITION}, Which バージョン @value{VERSION}
63 @subtitle @value{UPDATED}
64 @c !BEGIN AUTHORS
65 @author Carlo Wood <@email{carlo@@gnu.org}>
66 @c !END AUTHORS
67 @page
68 @vskip 0pt plus 1filll
69 Copyright @copyright{} 2000 - 2015, by
70
71 Carlo Wood, Run on IRC <carlo@@alinoe.com> RSA-1024 0x624ACAD5 1997-01-26
72 Sign & Encrypt Fingerprint16 = 32 EC A7 B6 AC DB 65 A6 F6 F6 55 DD 1C DC FF
73 61
74
75 @end titlepage
76
77 @ifnottex
78 @node Top, which プログラム, (dir), (dir)
79 @top @command{which}: コマンドのフルパス表示
80 @end ifnottex
81
82 @ifinfo
83 @c !BEGIN NAME
84 @c !END NAME
85 @command{which} プログラムは(シェル)コマンドのフルパスを表示します。
86
87 @noindent
88 This file documents @command{which} version @value{VERSION}, updated
89 @value{UPDATED}.
90 @end ifinfo
91
92 @menu
93 * which プログラム::    @command{which} プログラム
94 * which の起動::          @command{which} の起動方法
95 * オプションの概要::  コマンドラインオプションの概要
96 * 返り値::                @command{which} が返す値
97 * 例::                      コマンドの実行例
98 * バグ::                   既知のバグ
99 * 関連項目::             関連する UNIX コマンド
100 * さくいん::             さくいん
101 @end menu
102
103 @node which プログラム, which の起動, Top, Top
104 @chapter @command{which} プログラム
105 @cindex Description of @command{which}
106
107 @c !BEGIN DESCRIPTION
108 @c !END DESCRIPTION
109 @command{which} は 1
110 つまたは複数の引数を取ります。その引数それぞれに対して、その引数がシェルプロンプトから入力された際に、実行されることになる実行モジュールのフルパスを
111 stdout に出力します。 これを実現する際には、環境変数 @env{PATH} に列記されたディレクトリ内から実行ファイルやスクリプトを検索します。
112 これは @command{bash(1)} と同じアルゴリズムを用いています。
113
114 @node which の起動, オプションの概要, which プログラム, Top
115 @chapter @command{which} の実行
116 @cindex @command{which} の実行
117 @cindex Synopsis
118
119 @noindent
120 @command{which} の実行書式は以下のとおりです。
121
122 @c !BEGIN SYNOPSIS
123 @example
124 which [options] [--] programname [...]
125 @end example
126 @c !END SYNOPSIS
127
128 @menu
129 * オプションの概要::  オプション概要
130 @end menu
131
132 @node オプションの概要, 返り値, which の起動, Top
133 @chapter オプションの概要
134 @cindex Options, command line
135 @cindex Command line Options
136 @cindex Overview of command line options
137
138 @c !BEGIN OPTIONS
139 @table @samp
140 @cindex @option{--all}
141 @cindex @option{-a}
142 @item --all
143 @itemx -a
144 @env{PATH} において見つかった実行ファイルをすべて表示します。最初に見つかった一つだけではありません。
145
146 @cindex @option{--read-alias}
147 @cindex @option{-i}
148 @item --read-alias
149 @itemx -i
150 標準入力からエイリアスを読み込んで、合致したものを標準出力します。 これは which そのものを含む alias
151 において、本オプションを合わせて利用すると便利です。 たとえば以下です。@* @code{alias which='alias | which -i'}
152
153 @cindex @option{--skip-alias}
154 @item --skip-alias
155 @option{--read-alias} が指定されても無視します。which に対するエイリアスや関数の中で
156 @option{--read-alias} オプションを利用している場合であっても、明示的に通常の実行ファイルを検索する場合に利用できます。
157
158 @cindex @option{--read-functions}
159 @item --read-functions
160 標準入力からシェル関数定義を読み込んで、合致したものを標準出力します。これは which
161 そのものを含むシェル関数において、本オプションを合わせて利用すると便利です。たとえば以下です。@* @code{which() @{ declare
162 -f | which --read-functions $@@ @}@*export -f which}
163
164 @cindex @option{--skip-functions}
165 @item --skip-functions
166 @option{--read-functions} が指定されても無視します。which に対するエイリアスや関数の中で
167 @option{--read-functions} オプションを利用している場合であっても、明示的に通常の実行ファイルを検索する場合に利用できます。
168
169 @cindex @option{--skip-dot}
170 @item --skip-dot
171 @env{PATH} 内のディレクトリにうち、ドットで始まるディレクトリは除外します。
172
173 @cindex @option{--skip-tilde}
174 @item --skip-tilde
175 チルダで始まる @env{PATH} 内のディレクトリ、および @env{HOME} ディレクトリ内に存在する実行ファイルは除外します。
176
177 @cindex @option{--show-dot}
178 @item --show-dot
179 @env{PATH} 内にドットで始まるディレクトリがあって、合致した実行ファイルがその中に見つかった場合には、フルパスでなく
180 "./programname" と表示します。
181
182 @cindex @option{--show-tilde}
183 @item --show-tilde
184 ディレクトリが @env{HOME} に合致した場合、チルダを表示します。 このオプションは root ユーザーが実行した際には無視されます。 
185
186 @cindex @option{--tty-only}
187 @item --tty-only
188 tty 上でない場合、この右側に指定されたオプションの実行を停止します。
189
190 @cindex @option{--version}
191 @cindex @option{-v}
192 @cindex @option{-V}
193 @item --version, -v, -V
194 バージョン情報を標準出力して正常終了します。
195
196 @cindex @option{--help}
197 @item --help
198 利用方法を標準出力して正常終了します。
199
200 @end table
201 @c !END OPTIONS
202
203 @node 返り値, 例, オプションの概要, Top
204 @chapter 返り値
205 @cindex Return value of @command{which}
206
207 @c !BEGIN RETURNVALUE
208 @c !END RETURNVALUE
209 @command{which} は、処理に失敗した引数の数を返します。また @file{programname} が指定されなかった場合は -1
210 を返します。
211
212 @node 例, バグ, 返り値, Top
213 @chapter 例
214 @cindex Examples
215 @cindex aliases, handling of
216
217 @c !BEGIN EXAMPLE
218 本ユーティリティーを利用するには、@command{which} に対して、エイリアスを追加する (C シェルの場合) 、あるいはシェル関数を追加する
219 (Bourne シェル) 方法が推奨されます。たとえば以下のようにします。
220
221 [ba]sh:
222
223 @example
224 @group
225 which ()
226 @{
227   (alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@@
228 @}
229 export -f which
230 @end group
231 @end example
232
233 [t]csh:
234
235 @example
236 @group
237 alias which 'alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
238 @end group
239 @end example
240
241 @noindent
242 この方法にすると、端末から起動した際には、わかりやすく ~/ や ./ を表示します。一方でスクリプトから実行した際には、フルパスを表示します。
243
244 @example
245 @group
246 > which q2
247 ~/bin/q2
248 > echo `which q2`
249 /home/carlo/bin/q2
250 @end group
251 @end example
252 @c !END EXAMPLE
253
254 @node バグ, 関連項目, 例, Top
255 @chapter バグ
256 @cindex Bugs, known
257
258 @c !BEGIN BUGS
259 @c !END BUGS
260 @env{HOME} ディレクトリは、環境変数 @env{HOME}
261 を調べることで決定されますが、この変数が存在しない場合には、その処理がキャンセルされます。@command{which} は 2
262 つの同等のディレクトリであっても、その 1 つにシンボリックリンクを使ったパスが含まれている場合に、別のディレクトリと取り扱ってしまいます。
263
264 @node 関連項目, さくいん, バグ, Top
265 @chapter 関連項目
266
267 @c !BEGIN SEEALSO
268 @c !END SEEALSO
269 @command{bash(1)}
270
271 @node さくいん, , 関連項目, Top
272 @comment node-name,    next,  previous,       up
273 @unnumbered さくいん
274
275 @printindex cp
276
277 @contents
278 @bye