OSDN Git Service

バージョンの修正.
[omake-japanese/omake_trans.git] / osh.rst
1 .. 15-osh
2
3 .. _label15:
4
5 15. OSHシェル
6 ==================================
7 .. OMake also includes a standalone command-line interpreter osh that can be used as an interactive shell. The shell uses the same syntax, and provides the same features on all platforms omake supports, including Win32.
8
9 OMakeはまた、独立して動くコマンドラインインタープリタ ``osh`` を含んでいます。これはインタラクティブなシェルとして使うことができます。このシェルはomakeと同様の構文で利用することができ、さらにWin32を含む、omakeがサポートしているすべてのプラットフォーム上で同様の機能を提供します。
10
11 .. index::
12    single: prompt
13    single: ignoreeof
14 .. _label15.1:
15
16 15.1 起動時
17 ----------------------------------
18 .. On startup, osh reads the file ~/.oshrc if it exists. The syntax of this file is the same as an OMakefile. The following additional variables are significant.
19
20 起動時に、oshは存在しているのであれば ``~/.oshrc`` を読み込みます。このファイルの構文は ``OMakefile`` と同様です。また、以下の追加された変数は、osh上で重要な意味を持ちます。
21
22 * **prompt**
23   
24   .. The prompt variable specifies the command-line prompt. It can be a simple string.
25   
26   ``prompt`` 変数はコマンドラインプロンプトを指定します。この変数は単純な文字列を指定できます。 ::
27   
28       prompt = osh>
29   
30   .. Or you may choose to define it as a function of no arguments.
31   
32   あるいは、引数をもたない関数として定義することもできます。 ::
33   
34       prompt() =
35           return $"<$(USER):$(HOST) $(homename $(CWD))>"
36   
37   .. An example of the latter prompt is as follows.
38   
39   後者のプロンプトの例は以下のようになります。 ::
40
41       <jyh:kenai.yapper.org ~>cd links/omake
42       <jyh:kenai.yapper.org ~/links/omake>
43   
44   .. If you include any "invisible" text in the prompt (such as various terminal escape sequences), they must be wrapped using the prompt-invisible function. For example, to create a bold prompt on terminals that support it, you can use the following.
45   
46   プロンプト上にターミナルのエスケープ文字のような『見えない』文字を含ませたい場合は、 ``prompt-invisible`` 関数( :ref:`label10.11.26` )を使ってラップさせなければなりません。例えば、サポートしているターミナル上でプロンプトを太字にしたい場合、以下のように書くことができます。 ::
47
48         prompt =
49            bold-begin = $(prompt-invisible $(tgetstr bold))
50            bold-end = $(prompt-invisible $(tgetstr sgr0))
51            value $(bold-begin)$"osh>"$(bold-end)
52
53 * **ignoreeof**
54   
55   .. If the ignoreeof is true, then osh will not exit on a terminal end-of-file (usually ^D on Unix systems).
56   
57   ``ignoreeof`` が ``true`` の場合、 ``osh`` はターミナルの"end-of-file(EOF)"で終了しません(Unixシステム上では通常 ``^D`` となります)。
58
59 .. index::
60    single: Shell
61 .. _label15.2:
62
63 15.2 エイリアス
64 ----------------------------------
65 .. Command aliases are defined by adding functions to the Shell. object. The following alias adds the -AF option to the ls command.
66
67 コマンドのエイリアスは ``Shell.`` オブジェクトに関数を追加することによって定義できます。以下のエイリアスは ``-AF`` オプションを ``ls`` コマンドに追加します。 ::
68
69     Shell. +=
70        ls(argv) =
71           "ls" -AF $(argv)
72
73 .. Quoted commands do not undergo alias expansion. The quotation "ls" prevents the alias from being recursive.
74
75 クオートされたコマンドはエイリアス展開の影響を受けません。 ``"ls"`` のようにクオーテーションをつけることで、再帰的にエイリアスとなることを防ぎます。
76
77 .. _label15.3:
78
79 15.3 インタラクティブな構文
80 -------------------------------------
81 .. The interactive syntax in osh is the same as the syntax of an OMakefile, with one exception in regard to indentation. The line before an indented block must have a colon at the end of the line. A block is terminated with a . on a line by itself, or ^D. In the following example, the first line if true has no body, because there is no colon.
82
83 ``osh`` でのインタラクティブな構文はインデントという一つの例外を除いて、 ``OMakefile`` の構文と同様です。まず、インデントされたブロックの前にある行は、必ず行の終わりにコロン:をつける必要があります。次に、 ``.`` を行の終わりにつけるか ``^D`` を使うことで、対象のブロックを終了させます。以下の例では、最初の行の ``if true`` はコロンをつけていないため、内容のブロックを持つことはできません。 ::
84
85    # 以下のifは内容を持ちません
86    osh>if true
87    # 以下のifは内容を持ちます
88    osh>if true:
89    if>       if true:
90    if>          println(Hello world)
91    if>          .
92    Hello world
93
94 .. Note that osh makes some effort to modify the prompt while in an indented body, and it auto-indents the text.
95
96 インデントされたブロックの中にいる際には、プロンプトをいくらか修正する必要があり、かつ ``osh`` は自動的にテキストをインデントすることに注意してください。
97
98 .. The colon signifier is also allowed in files, although it is not required.
99
100 また、コロン修飾子はファイルにも適用できますが、必須ではありません。