1 \input texinfo-ja @c -*-texinfo-*-
2 @c ===========================================================================
4 @c This file was generated with po4a. Translate the source file.
6 @c ===========================================================================
9 @setfilename which.info
10 @documentencoding UTF-8
12 @settitle @command{which}: コマンドのフルパス表示
14 @dircategory System administration
16 * Which: (which). コマンドのフルパスを表示
20 @setchapternewpage odd
27 このファイルは `which' version 2.x@ を説明するものです。
30 Copyright @copyright{} 2000 - 2015, by
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
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.
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
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
62 @subtitle 編集版 @value{EDITION}, Which バージョン @value{VERSION}
63 @subtitle @value{UPDATED}
65 @author Carlo Wood <@email{carlo@@gnu.org}>
68 @vskip 0pt plus 1filll
69 Copyright @copyright{} 2000 - 2015, by
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
78 @node Top, which プログラム, (dir), (dir)
79 @top @command{which}: コマンドのフルパス表示
85 @command{which} プログラムは(シェル)コマンドのフルパスを表示します。
88 This file documents @command{which} version @value{VERSION}, updated
93 * which プログラム:: @command{which} プログラム
94 * which の起動:: @command{which} の起動方法
95 * オプションの概要:: コマンドラインオプションの概要
96 * 返り値:: @command{which} が返す値
99 * 関連項目:: 関連する UNIX コマンド
103 @node which プログラム, which の起動, Top, Top
104 @chapter @command{which} プログラム
105 @cindex Description of @command{which}
107 @c !BEGIN DESCRIPTION
110 つまたは複数の引数を取ります。その引数それぞれに対して、その引数がシェルプロンプトから入力された際に、実行されることになる実行モジュールのフルパスを
111 stdout に出力します。 これを実現する際には、環境変数 @env{PATH} に列記されたディレクトリ内から実行ファイルやスクリプトを検索します。
112 これは @command{bash(1)} と同じアルゴリズムを用いています。
114 @node which の起動, オプションの概要, which プログラム, Top
115 @chapter @command{which} の実行
116 @cindex @command{which} の実行
120 @command{which} の実行書式は以下のとおりです。
124 which [options] [--] programname [...]
132 @node オプションの概要, 返り値, which の起動, Top
134 @cindex Options, command line
135 @cindex Command line Options
136 @cindex Overview of command line options
140 @cindex @option{--all}
144 @env{PATH} において見つかった実行ファイルをすべて表示します。最初に見つかった一つだけではありません。
146 @cindex @option{--read-alias}
150 標準入力からエイリアスを読み込んで、合致したものを標準出力します。 これは which そのものを含む alias
151 において、本オプションを合わせて利用すると便利です。 たとえば以下です。@* @code{alias which='alias | which -i'}
153 @cindex @option{--skip-alias}
155 @option{--read-alias} が指定されても無視します。which に対するエイリアスや関数の中で
156 @option{--read-alias} オプションを利用している場合であっても、明示的に通常の実行ファイルを検索する場合に利用できます。
158 @cindex @option{--read-functions}
159 @item --read-functions
160 標準入力からシェル関数定義を読み込んで、合致したものを標準出力します。これは which
161 そのものを含むシェル関数において、本オプションを合わせて利用すると便利です。たとえば以下です。@* @code{which() @{ declare
162 -f | which --read-functions $@@ @}@*export -f which}
164 @cindex @option{--skip-functions}
165 @item --skip-functions
166 @option{--read-functions} が指定されても無視します。which に対するエイリアスや関数の中で
167 @option{--read-functions} オプションを利用している場合であっても、明示的に通常の実行ファイルを検索する場合に利用できます。
169 @cindex @option{--skip-dot}
171 @env{PATH} 内のディレクトリにうち、ドットで始まるディレクトリは除外します。
173 @cindex @option{--skip-tilde}
175 チルダで始まる @env{PATH} 内のディレクトリ、および @env{HOME} ディレクトリ内に存在する実行ファイルは除外します。
177 @cindex @option{--show-dot}
179 @env{PATH} 内にドットで始まるディレクトリがあって、合致した実行ファイルがその中に見つかった場合には、フルパスでなく
180 "./programname" と表示します。
182 @cindex @option{--show-tilde}
184 ディレクトリが @env{HOME} に合致した場合、チルダを表示します。 このオプションは root ユーザーが実行した際には無視されます。
186 @cindex @option{--tty-only}
188 tty 上でない場合、この右側に指定されたオプションの実行を停止します。
190 @cindex @option{--version}
193 @item --version, -v, -V
194 バージョン情報を標準出力して正常終了します。
196 @cindex @option{--help}
203 @node 返り値, 例, オプションの概要, Top
205 @cindex Return value of @command{which}
207 @c !BEGIN RETURNVALUE
209 @command{which} は、処理に失敗した引数の数を返します。また @file{programname} が指定されなかった場合は -1
212 @node 例, バグ, 返り値, Top
215 @cindex aliases, handling of
218 本ユーティリティーを利用するには、@command{which} に対して、エイリアスを追加する (C シェルの場合) 、あるいはシェル関数を追加する
219 (Bourne シェル) 方法が推奨されます。たとえば以下のようにします。
227 (alias; declare -f) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@@
237 alias which 'alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
242 この方法にすると、端末から起動した際には、わかりやすく ~/ や ./ を表示します。一方でスクリプトから実行した際には、フルパスを表示します。
254 @node バグ, 関連項目, 例, Top
260 @env{HOME} ディレクトリは、環境変数 @env{HOME}
261 を調べることで決定されますが、この変数が存在しない場合には、その処理がキャンセルされます。@command{which} は 2
262 つの同等のディレクトリであっても、その 1 つにシンボリックリンクを使ったパスが含まれている場合に、別のディレクトリと取り扱ってしまいます。
264 @node 関連項目, さくいん, バグ, Top
271 @node さくいん, , 関連項目, Top
272 @comment node-name, next, previous, up