Line command interpreter

The SIRTX shell

The line command interpreter is the basic shell of SIRTX. It allows the user to interact with the system, software, and hardware.

Each line is interpreted as a call to a function with a number of inputs and outputs (called ports) set. The basic syntax is optimised for performing well with the limited resources as well as a wide range of input devices. Specifically input devices that lack support for alphabetical input are supported (such as numerical only keyboards).

Each line is a list of port-value pairs seperated by delimiters. Spaces and commas are accepted as delimiters, as well as equal signs when a port is specifically named.

Each value corresponds to a tag, or a degenerated tag such as a string or numeric value.

Please note that not all options may be available depending on the selected build options of the target.

Examples
~> echo "Hello World!"
Hello World!
~> show null
T:  6517 "/dev/null"
   Relation                        Related/Type                    Data
   # Context                         Encoding
   --------------------------------------------------------------------
M:     1 "also-shares-id..."           2 "uuid"                    '44c76593-2d72-57bc-b3f9-a85a0c75832b'
M:     1 "also-shares-id..."           3 "tagname"                 '/dev/null'
M:     1 "also-shares-id..."           4 "wikidata-ident..."       'Q14671'
M:     1 "also-shares-id..."       10981 "sirtx-logical"           'null'
R:  4580 "instance of"                                        6518 "device file"
R:  4580 "instance of"                                        6519 "zero-byte file"

Syntax

Basic syntax

The basic syntax is a list of key-value pairs called ports. Each port is identified by a tag called name and has a value. If the name of the port is not specifically given a default is used.

The first port that has no name assigned to it is used as the function to call.

Elements of the list are seperated by one or more of space (" "), comma (","), or full stop ("."). Full stop is supported only for keyboards not supporting comma on the numerical block. It should not be used when there is access to one of the others.

Syntax
[-name=][filters…]value, …
Example
echo "Hello world" -stdout=null

Tags

Tags can be used both as names and values. If used as values modifiers can be used with them.

A tag can be given in number of different ways:

Syntax Example Explanation
number
1234
By the tag's numerical id
/number
/123
By the tag's program number
*number
*12
By the tag's current local id
&tag
&stdin
By dereference
logical
or
program-name
null
By the tags logical or program name
tag:id
sid:1
By identifier type and identifier
tag:tag:id
asi:sid:1
By relation, type, and identifier

In addition, it is possible to quote the identifier using "[" and "]". This allows the use of identifiers that contain characters that are otherwise considered control characters. The most notable example of this is "-".

Examples
show stdin
echo &ac
help [sirtx-logical]
help uuid:[5e80c7b7-215e-4154-b310-a5387045c336]

Values

A value can be a tag, or a degenerated tag like a number or a string. A value can also have modifiers attached to it. Modifiers are given in front of the value.

Numeric values are prefixed with a single quote ("'").

Strings are given by using double quotes. Inside the double quotes any character can be escaped using backslash notation. The following escapes are supported:

Escape Example Explanation
\
"test\\n"
Escapes the escape
0
"record 0\0record 1"
The nil byte (0x00, NUL)
n
"line 0\nline 1"
The newline character (0x0a, LF)
t
"text\twith\ttabs"
Horizontal tabulator (0x09, HT)
e
"\e[0m"
Escape (0x1b, ESC)
xHH
"te\x7fst"
Escape any character based on its hexadecimal value

Modifiers provide additional infos such as the access mode. The following modifiers can be prefixed:

Modifier Example Explanation
<
<null
Open for read
>
>null
Open for write
@
@ctty
Open with driver in online state
Examples
echo "Hello World!"
echo '1234
transfer "test" @ctty
hexdump <*0

Filters

Filters can be used to transform one value into another. This is a concept similar to both pipes on UNIX and TSR on DOS.

Filters take an input (right side), provide an output (left side), and may optionally take arguments.

Filters are enclosed in brackets ("(…)") before the value they should transform.

Examples
echo (rot13)"Hello world!"
context -stdout=(more)&stdout

Variables

Variables (historically also called "shellstore") are used to store values between function calls. Variables need to be declared (with a name) and can then be set to a value. They are visible to called functions by the function looking them up or by passing them via a port.

Variables are referenced via their tag. The current content of a variable is used by prefixing the variable with an ampersand ("&").

Notable function acting on variables are "declare", "set", and "swap". Also, "context" can be used to list the currently defined variables.

A general purpose variable is the accumulator (logical "ac"). It can be used as a temporary storage.

Examples
set &ac @ctty
echo &wd:Q47517785
8391 (* 0) "Line command interpreter" ~>