[JM:00090] Re: [POST:RO] GNU_findutils find.1

Back to archive index

Akihiro MOTOKI amoto****@gmail*****
2010年 12月 28日 (火) 02:12:43 JST


元木です。

続けて、EXPRESSIONS の節です (2/3)。
3/3 は明日にしたいと思います。

> .\"O .SH EXPRESSIONS
> .\"O The expression is made up of options (which affect overall operation
> .\"O rather than the processing of a specific file, and always return
> .\"O true), tests (which return a true or false value), and actions (which
> .\"O have side effects and return a true or false value), all separated by
> .\"O operators.  
> .\"O .B \-and
> .\"O is assumed where the operator is omitted.  
> .\"O 
> .SH "式 (EXPRESSIONS)"
> 式は、オプション、判別式、アクションから構成されている
> (訳注: オプション、判別式、アクションをまとめて、「述語 predicate」と呼ぶ)。

やはり、訳語に対するオリジナルの用語である predicate は
括弧で囲んでおきたいと感じました。

> オプションは特定のファイルの処理よりもむしろ作業全体に影響し、
> 常に真を返す。判別式が返す値は、真のこともあれば、偽のこともある。
> アクションには付加的な作用があり、真または偽を返す。
> こうした式の要素は、みな演算子で区切られる。演算子が省略された場所には、
> .B \-and
> があるものと見なされる。
> 
> .\"O .SS OPTIONS
> .\"O .P
> .\"O All options always return true.  Except for 
> .\"O .BR \-daystart , 
> .\"O .B \-follow
> .\"O and
> .\"O .BR \-regextype , 
> .\"O the options affect all tests, including tests specified
> .\"O before the option.  This is because the options are processed when the
> .\"O command line is parsed, while the tests don't do anything until files
> .\"O are examined.  The 
> .\"O .BR \-daystart , 
> .\"O .B \-follow 
> .\"O and 
> .\"O .B \-regextype
> .\"O options are different in this respect, and have an effect only on tests which
> .\"O appear later in the command line.  Therefore, for clarity, it is best
> .\"O to place them at the beginning of the expression.  A warning is issued
> .\"O if you don't do this.
> .\"O 
> .SS オプション
> .P
> すべてのオプションは常に真を返す。
> .BR \-daystart ,
> .BR \-follow ,
> .B \-regextype
> を除いて、そのほかのオプションは、そのオプションより前に
> 指定された判別式も含め、すべての判別式に影響を及ぼす。
> これは、オプションの処理は、コマンドラインが解析されるときに
> 行われるのに対して、判別式の方は、ファイルが調べられるまで
> 何もしないからである。
> .BR \-daystart ,
> .BR \-follow ,
> .B \-regextype
> の各オプションはこの点で異なっている。この三つのオプションは、
> コマンドラインで自分より後に指定された判別式にしか影響を
> 及ぼさないのだ。従って、混乱を避けるためには、オプションを
> 式の先頭部に置いた方がよい。そうしないと、警告が発せられる。

最後の文ですが、これら 3つのオプションを式の先頭部に置かなかった場合の
話なので、「そうしないと〜」というより「そうしなかった場合」とか
「先頭以外で指定した場合」とかの方が読みやすいかもしれません。

また、「混乱を避けるためには、オプションを式の先頭部に置いた方がよい。」
についてですが、「オプション」は実際には例外的な動作をする
3つのオプションのことなので、
「これらのオプションは式の先頭に置いた方がよい」のように、
オプションを限定する表現はいかがでしょうか。

> .\"O .IP \-daystart
> .\"O Measure times (for 
> .\"O .BR \-amin , 
> .\"O .BR \-atime , 
> .\"O .BR \-cmin , 
> .\"O .BR \-ctime , 
> .\"O .BR \-mmin , 
> .\"O and 
> .\"O .BR \-mtime )
> .\"O from the beginning of today rather than from 24 hours ago.  This
> .\"O option only affects tests which appear later on the command line.
> .\"O 
> .IP \-daystart
> .BR \-amin , 
> .BR \-atime , 
> .BR \-cmin , 
> .BR \-ctime , 
> .BR \-mmin , 
> .B \-mtime
> において、今日 (すなわち 0 日前) の始まりを今現在から 24 時間前ではなく、
> コマンド実行当日の 0 時にする。
> このオプションが影響を及ぼすのは、コマンドラインで自分より後に
> 指定された判別式だけである。(訳注: なお、ちょっと変な表現になるが、
> .BR \-amin ,
> .BR \-cmin ,
> .B \-mmin
> のことも考えに入れると、「デフォルトでは時間を計算するときの基準を
> 今現在に置くが、
> .B \-daystart
> を指定すると、時間計算の基準が今日の 24:00 になる」
> と言えばよいのかもしれない。)

訳注の「ちょっと変な表現になるが」は不要かと思います。

   訳注 : -amin, -cmin, -mmin のことも考慮に入れると、
   時間計算の基準が 今現在から今日の 24:00 になる、と考えると
   分かりやすいかもしれない。

といった感じではいかがでしょうか。

> .\"O .IP "\-help, \-\-help"
> .\"O Print a summary of the command-line usage of
> .\"O .B find
> .\"O and exit.
> .\"O 
> .IP "\-help, \-\-help"
> .B find
> のコマンドラインの使用法をざっと説明して終了する。

「使用法の概要を表示して終了する」くらいはいかがでしょうか。

> .\"O .IP "\-noleaf"
> .\"O Do not optimize by assuming that directories contain 2 fewer
> .\"O subdirectories than their hard link count.  This option is needed when
> .\"O searching filesystems that do not follow the Unix directory-link
> .\"O convention, such as CD-ROM or MS-DOS filesystems or AFS volume mount
> .\"O points.  Each directory on a normal Unix filesystem has at least 2
> .\"O hard links: its name and its `.'  entry.  Additionally, its
> .\"O subdirectories (if any) each have a `..'  entry linked to that
> .\"O directory.  When
> .\"O .B find
> .\"O is examining a directory, after it has statted 2 fewer subdirectories
> .\"O than the directory's link count, it knows that the rest of the entries
> .\"O in the directory are non-directories (`leaf' files in the directory
> .\"O tree).  If only the files' names need to be examined, there is no need
> .\"O to stat them; this gives a significant increase in search speed.
> .\"O 
> .IP "\-noleaf"
> 「ディレクトリのハードリンク数から 2 を引いたものが、そのディレクトリに
> 含まれるサブディレクトリの数である」とする最適化動作を行わない。
> このオプションが必要になるのは、ディレクトリとリンクの関係について
> Unix の流儀に従わないファイルシステムを探索するときだ。
> たとえば、CD-ROM や MS-DOS のファイルシステムとか、AFS ボリュームの
> マウントポイントなどを探索するときである。
> 通常の Unix ファイルシステムでは、各ディレクトリは少なくとも
> 2 個のハードリンクを持っている。ディレクトリ名のエントリと、
> そのディレクトリ中の `.' エントリである。さらに、そのディレクトリに
> サブディレクトリがあれば、サブディレクトリそれぞれに、親ディレクトリに
> ハードリンクした '..' エントリが存在する。
> .B find
> としては、ディレクトリを調べる際に、ディレクトリのリンク数より 2 少ない
> 数だけサブディレクトリを stat 関数で調べた時点で、ディレクトリ中の
> 残りのエントリはディレクトリではない (ディレクトリツリー中の
> `leaf 葉っぱ' ファイルである) とわかるわけである。
> もし、調べるのがファイル名だけで充分なら、ファイルに対して stat 関数を
                                  ^^^^
「充分」→「十分」でしょうか

> 実行する必要はない。そこで、この動作により、検索速度が
> いちじるしく向上するわけだ。

> .\"O Numeric arguments can be specified as
> .\"O .IP \fI+n\fP
> .\"O for greater than
> .\"O .IR n ,
> .\"O .IP \fI\-n\fP
> .\"O for less than
> .\"O .IR n ,
> .\"O .IP \fIn\fP
> .\"O for exactly
> .\"O .IR n .
> .\"O .P
> .\"O
> 数値の引き数は、以下の形で指定することができる。
> .IP \fI+n\fP
> .I n
> を越える数であることを意味する。

「n より大きい数」などはどうでしょうか。

> .IP \fI\-n\fP
> .I n
> 未満であることを意味する。
> .IP \fIn\fP
> ぴったり
> .I n
> であることを意味する。

[...]

> .\"O .IP "\-ok \fIcommand\fR ;"
> .\"O Like 
> .\"O .B \-exec
> .\"O but ask the user first.  If the user agrees, run the command.  Otherwise
> .\"O just return false.  If the command is run, its standard input is redirected
> .\"O from
> .\"O .BR /dev/null .
> .\"O 
> .IP "\-ok \fIcommand\fR ;"
> .B \-exec
> と似ているが、まずユーザに問い合わせを行う。ユーザーが同意すれば、
> コマンドを実行する。同意しなければ、何もせずに偽を返す。
> コマンドを実行する際、そのコマンドの標準入力は、
> .B /dev/null
> に付け換えられる。
> 
> .\"O .IP
> .\"O The response to the prompt is matched against a pair of regular
> .\"O expressions to determine if it is an affirmative or negative
> .\"O response.  This regular expression is obtained from the system if the
> .\"O `POSIXLY_CORRECT' environment variable is set, or otherwise from 
> .\"O .BR find 's 
> .\"O message translations.  If the system has no suitable
> .\"O definition, 
> .\"O .BR find 's 
> .\"O own definition will be used.   In either case, the interpretation of
> .\"O the regular expression itself will be affected by the environment
> .\"O variables 'LC_CTYPE' (character classes) and 'LC_COLLATE' (character
> .\"O ranges and equivalence classes).
> .\"O 
> .\"O 
> .\"O 
> .IP
> プロンプトに対する応答は、肯定・否定を表す一組の正規表現と突き合わせて、
> 同意か、不同意かが判断される。

日本語だけ読んでいると、なかなか難解でした。

原文もそうなのですが、「プロンプト」はここで初めて登場するので、
ユーザに対する問い合わせとの関係が分かるといいかなと思いました。
「プロンプトに対するユーザの応答は〜」などはいかがでしょうか。

「肯定・否定を表す一組の正規表現と突き合わせて、」の
「突き合わせて」ですが、「照合され」はいかがでしょうか。

> この正規表現は、環境変数 `POSIXLY_CORRECT' が
> 設定されていれば、システムから得られるが、設定されていない場合は、
> .B find
> のメッセージ・トランスレーションから取得される。システムに

「POSIXLY_CORRECT が設定されている場合はシステムから取得され」
のように、その直後の文と韻を合わせると読みやすいと思いますが、
いかがでしょうか。

「メッセージ・トランスレーション」はそれほど一般的な用語ではないと
思いますが、訳もなかなか難しいですね。強いて訳すとしたら、
「find が持つメッセージ翻訳データベースから取得される」くらいかなぁ。

> 適切な定義が存在しない場合は、
> .B find
> 自体の定義が使用されることになる。どちらの場合でも、正規表現そのものの
> 解釈は、環境変数 'LC_CTYPE' (文字クラスにについて) や 'LC_COLLATE'
> (文字の範囲や等価クラスについて) の影響を受ける。

[...]

> .\"O .IP "\-printf \fIformat\fR"
> .\"O True; print \fIformat\fR on the standard output, interpreting `\e'
> .\"O escapes and `%' directives.  Field widths and precisions can be
> .\"O specified as with the `printf' C function.  Please note that many of
> .\"O the fields are printed as %s rather than %d, and this may mean that
> .\"O flags don't work as you might expect.  This also means that the `\-'
> .\"O flag does work (it forces fields to be left-aligned).  Unlike 
> .\"O .BR \-print ,
> .\"O .B \-printf
> .\"O does not add a newline at the end of the string.  The escapes
> .\"O and directives are:
> .IP "\-printf \fIformat\fR"
> 真を返す。標準出力に \fIformat\fR を出力する。そのとき `\e' を
> エスケープ文字の、`%' を書式指定子の始めとして解釈する。

申し訳ありませんが、この文もちょっと読み辛かったです。

   '\e' はエスケープ文字として、'%' は書式指定子として解釈される、

などでもよいのではないでしょうか?

厳密には長南さんの訳のように「〜の始め」の方が正確かもしれませんが、
バックスラッシュをエスケープ文字と呼ぶのは比較的一般的だと思います。

> フィールドの幅や精度は、C 言語の `printf' 関数と同じやり方で
> 指定できる。フィールドの多くは、%d ではなく、%s として
> 出力されることに注意していただきたい。すなわち、フラグが期待通りに
> 効かないかもしれないのだ。だが、それはまた、`\-' フラグが
> 使えるということでもある (フィールドを強制的に左揃えにする)。

括弧内は '\-' フラグの直後に置いた方が読みやすいと思いました。

> .\"O A `%' character followed by any other character is discarded, but the
> .\"O other character is printed (don't rely on this, as further format
> .\"O characters may be introduced).  A `%' at the end of the format
> .\"O argument causes undefined behaviour since there is no following
> .\"O character.  In some locales, it may hide your door keys, while in
> .\"O others it may remove the final page from the novel you are reading.
> .\"O 
> 一個の `%' に上記以外の文字が続く場合、`%' 文字は捨てられるが、
> それに続く文字は表示される (書式指定文字が新たに追加されるかもしれないので、
> この動作を当てにしてはいけない)。書式指定の末尾に `%' があるときの動作は、
> 続く文字がないので不定である。あるロケールでは、お宅のドアの鍵が
> 見つからなくなるかもしれない。また、別のロケールでは、
> お読みの小説の最後のページが消えてしまうかもしれない。

これはユーモアの部分なので、(私も得意ではないのですが)

   ひょっとすると、ロケールによっては、家のドアの鍵が見つからなくなったり、
   お読みの小説の最後のページが消えてしまったりするかもしれませんよ。

といった感じでしょうか。

-- 
Akihiro MOTOKI (amoto****@dd***** / amoto****@gmail*****)




linuxjm-discuss メーリングリストの案内
Back to archive index