moros/doc/shell.md

124 lines
2.3 KiB
Markdown
Raw Normal View History

2019-12-30 21:33:06 +00:00
# MOROS Shell
## Commands
The main commands have a long name, a one-letter alias, and may have
additional common aliases.
2020-02-16 19:06:04 +00:00
<!--
**Alias** command:
2019-12-30 21:33:06 +00:00
> alias d delete
2019-12-30 21:33:06 +00:00
2020-02-16 19:06:04 +00:00
**Append** to file:
2020-01-06 21:26:31 +00:00
> a a.txt
> append a.txt
2020-02-16 19:06:04 +00:00
-->
2020-01-06 21:26:31 +00:00
2020-02-16 19:06:04 +00:00
**Delete** file:
2019-12-30 21:33:06 +00:00
> d a.txt
> del a.txt
> delete a.txt
2019-12-30 21:33:06 +00:00
2020-02-16 19:06:04 +00:00
**Copy** file:
2019-12-30 21:33:06 +00:00
> c a.txt b.txt
> copy a.txt b.txt
2019-12-30 21:33:06 +00:00
2020-02-16 19:06:04 +00:00
**Move** file:
2019-12-30 21:33:06 +00:00
> m a.txt b.txt
> move a.txt b.txt
2019-12-30 21:33:06 +00:00
2020-02-16 19:06:04 +00:00
**Print** string:
2019-12-30 21:33:06 +00:00
> p "Hi"
> print "Hi"
2019-12-30 21:33:06 +00:00
2020-02-16 19:06:04 +00:00
**Read** file:
2019-12-30 21:33:06 +00:00
> r a.txt
> read a.txt
2019-12-30 21:33:06 +00:00
2020-02-16 19:06:04 +00:00
**Write** file:
2019-12-30 21:33:06 +00:00
> w a.txt
> write a.txt
2019-12-30 21:33:06 +00:00
2020-02-16 19:06:04 +00:00
**Write** dir:
2019-12-30 21:33:06 +00:00
> write /usr/alice/ # with a trailing slash to create a dir instead of a file
2019-12-30 21:33:06 +00:00
2020-02-16 19:06:04 +00:00
**List** files in dir:
> list /usr/alice
2020-02-16 19:06:04 +00:00
When executed without arguments, this command will list the files of the
current directory.
**Go to** dir:
> goto /usr/alice
2020-02-16 19:06:04 +00:00
When executed without arguments, this command will print the current directory.
## Combiners (TODO)
2019-12-30 21:33:06 +00:00
The `&` and `|` symbols are used only for combiners so there's no needs to
double them.
2019-12-31 07:40:17 +00:00
**And combiner:**
2019-12-30 21:33:06 +00:00
> r a.txt & r b.txt
2019-12-30 21:33:06 +00:00
2019-12-31 07:40:17 +00:00
**Or combiners:**
2019-12-30 21:33:06 +00:00
> r a.txt | r b.txt
2019-12-30 21:33:06 +00:00
## Pipes (TODO)
2019-12-30 21:33:06 +00:00
The pipe symbol `|` from UNIX is replaced by a thin arrow `->`, shortened to
`>`, and the redirection symbol `>` from UNIX is replaced by a fat arrow `=>`
(see below).
Piping the standard output of a program to the `write` command to emulate a
redirection for example would be `-> write` or `> w` in short.
An additional standard stream stdnull(3) is added to simplify writing to `/dev/null`.
Examples:
2019-12-30 21:33:06 +00:00
Read file A and redirect stdout(1) to stdin(0) of write file B:
> r a.txt > w b.txt
2021-02-07 12:00:17 +00:00
> r a.txt 1>0 w b.txt # with explicit streams
> r a.txt -> w b.txt # with thin arrow
2019-12-30 21:33:06 +00:00
Read file A and redirect stderr(2) to stdin(0) of write file B:
> r a.txt 2> w b.txt
> r a.txt 2>0 w b.txt
2019-12-30 21:33:06 +00:00
Suppress errors by redirecting stderr(2) to stdnull(3):
2019-12-30 21:33:06 +00:00
> r a.txt 2>3 w b.txt
2019-12-30 21:33:06 +00:00
Redirect stdout(1) to stdin(0) and stderr(2) to stdnull(3):
2019-12-30 21:33:06 +00:00
> r a.txt > 2>3 w b.txt
> r a.txt 1>0 2>3 w b.txt
## Redirections
Redirecting standard IO streams can be done with a fat arrow, for example the
output of the print command can be written to a file like so:
> print hello => /tmp/hello
Which is more efficient than doing:
> print hello -> write /tmp/hello