Jump to:  OMake Home • Guide Home • Guide (single-page) • Contents (short) • Contents (long)
Index:  All • Variables • Functions • Objects • Targets • Options

Chapter 15  The OSH shell

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.

15.1  Startup

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.


The prompt variable specifies the command-line prompt. It can be a simple string.

    prompt = osh>

Or you may choose to define it as a function of no arguments.

    prompt() =
        return $"<$(USER):$(HOST) $(homename $(CWD))>"

An example of the latter prompt is as follows.

    <jyh:kenai.yapper.org ~>cd links/omake
    <jyh:kenai.yapper.org ~/links/omake>

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.

    prompt =
       bold-begin = $(prompt-invisible $(tgetstr bold))
       bold-end = $(prompt-invisible $(tgetstr sgr0))
       value $(bold-begin)$"osh>"$(bold-end)

If the ignoreeof is true, then osh will not exit on a terminal end-of-file (usually ^D on Unix systems).

15.2  Aliases

Command aliases are defined by adding functions to the Shell. object. The following alias adds the -AF option to the ls command.

    Shell. +=
       ls(argv) =
          "ls" -AF $(argv)

Quoted commands do not undergo alias expansion. The quotation "ls" prevents the alias from being recursive.

15.3  Interactive syntax

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.

   # The following if has no body
   osh>if true
   # The following if has a body
   osh>if true:
   if>       if true:
   if>          println(Hello world)
   if>          .
   Hello world

Note that osh makes some effort to modify the prompt while in an indented body, and it auto-indents the text.

The colon signifier is also allowed in files, although it is not required.

Jump to:  OMake Home • Guide Home • Guide (single-page) • Contents (short) • Contents (long)
Index:  All • Variables • Functions • Objects • Targets • Options