Module oursh::program[][src]

Expand description

Parsing and handling program syntax(es) of the shell.

Both, commands entered to the shell interactively through STDIN, and read from a file, are programs. Our shell provides multiple discrete languages to write programs in, each with a corresponding implementation of this module’s Program trait.

POSIX Shell Language

The basic, portable POSIX shell language. For detailed information read the posix module docs.

for ((i=0; i<10; i++)); do echo $i; done

Modern Shell Language

A more modern and ergonomic language. For more detailed information read the modern module docs.

for i in (0..10) { echo $i }

Default Syntax

Our shell has a PrimaryProgram which is in charge of parsing programs which are not passed in via a {#} language block. This can be configured to your preference. This does not effect the shell when launched in POSIX compatibility mode, or when a specific default language is passed as a flag.

{#} Language Blocks

Both the posix and modern languages have support for a special expression which treats the body as a program from another language. This forms the basis of oursh’s modern features, and backwards compatibility. While the primary goal of this syntax is to be able to mix both POSIX and non-POSIX shell scripts, the feature is much more powerful. Any interperator can be used, just like with #!.

date      # Call `date` in the primary syntax.
{# date}  # Specifies the alternate syntax.

{#!ruby
    require 'date'
    puts Date.today
}

Strict POSIX compatibility can be enabled by removing this feature alone.

  • TODO #5: Parse sequence of programs from stream.
  • TODO #5: Partial parses for readline-ish / syntax highlighting.

Re-exports

pub use self::runtime::Runtime;
pub use self::basic::Program as BasicProgram;
pub use self::posix::Program as PosixProgram;
pub use self::modern::Program as ModernProgram;

Modules

Single command programs with no features.

The shell language (often called sh) at the heart of the most popular shells.

Enums

A comprehensive error type for the operation of programs.

Traits

A command is a task given by the user as part of a Program.

A program is as large as a file or as small as a line.

Functions

Parse a program of the given type.

Parse a program of the alternate type.

Parse a program of the primary type.

Type Definitions

TODO: alt explain

The primary program type, used for unannotated blocks.

Convenience type for results with program errors.