Skip to main content
Mirage’s shell combines commands from Core Tools and Data & Network with variables, control flow, and persistent sessions.

Syntax

Shell commands

These are common options, not an exhaustive flag reference.

Sessions and permissions

ws.shell(...) keeps the session’s working directory, variables, and functions between calls. Supplying cwd or env uses an isolated copy for that call. Calls on one session run in order; use separate sessions for concurrent command streams. Python accepts a cancellation event through cancel; TypeScript accepts an abort signal.

Jobs across instances

A workspace runs as several instances when more than one process builds it under the same workspace_id on one shared store, as Infrastructure shows. One of them runs its lines at a time, the first to run one; a line on any other is refused with an error naming it until it closes the workspace. Process IDs continue from the highest the workspace has used, so an instance that takes over never reuses one. If the running instance goes away without closing the workspace, another can run its lines about 30 seconds later. It reports the jobs left behind as ended with status 129, as Bash reports a hangup, and stops what they ran outside Mirage: a sandbox program through a runtime on the same machine, or a host program on the same machine whose PID still matches. A program a runtime runs outside Mirage is a process of its own. ps shows its real pid and the machine it runs on, a host program’s host PID or a machine’s. Mirage’s own commands show mirage:
Mirage’s pids start at 4194305, past any Linux pid, so $!, kill, wait and ps -p take either kind.

Per-session mount modes

Session mount modes can narrow access to read, write, or exec (r, rw, rwx). Unlisted mounts keep their configured modes. Interpreters such as python3 and js require exec; shell scripts run with the permissions of each command they contain. Use an session profile to hide paths or restrict commands.

Limits

  • Positive read -t values are accepted but do not enforce a timeout.
  • bg, complete, compgen, ulimit, coproc, and exec -a/-l are not implemented.
  • A process substitution’s /dev/fd/N path belongs to the command that opened it. An input producer can keep running after that command finishes. The command waits for output consumers. Opening an output substitution with exec 3> >(command) fails with exit status 2.
  • There is no interactive terminal or OS process job control. The supported job commands manage Mirage jobs: cmd &, jobs, wait and kill.
  • kill takes every Linux signal kill -l lists, by name or number. STOP pauses a job, which ps shows as T, and CONT lets it go on; a TERM sent meanwhile waits for the CONT. A Mirage command pauses at its next file operation, pipe write, sleep or loop turn, and in a browser STOP of one is refused. A Monty or Pyodide program pauses where it is, and a QuickJS or WASI program at its next file operation or output. Any other signal whose default is to be ignored or to pause a process (CHLD, URG, WINCH, TSTP, TTIN, TTOU) succeeds and changes nothing. A Pyodide program gets the signal as sent too, as does a program a runtime started on a machine or on the host: one that handles it runs on, and the job ends when the program exits, with its status. KILL is sent only for kill -9, timeout -k, or when the workspace shuts down. Any other process stops, and wait reports 128 plus the signal, as in Bash. As in Bash, a background job ignores INT and QUIT. Unlike Bash, kill also stops the jobs a job started and theirs, even once the job between them has ended.
  • When time runs out, timeout signals its command’s process group, as GNU timeout does, so the jobs the command started stop too. It doesn’t with --foreground, -s INT or -s QUIT.
  • A background job that gets INT acts as in Bash:
    • a job that is one program ignores it;
    • a job that runs several commands stops only its current command, subshell or pipeline, and goes on;
    • a job that runs a function ends.
  • Every line of a session runs as one shell process, $$, which leads the session’s process group; its jobs, pipeline stages, subshells, command substitutions and nested shells are in it. A negative operand signals a whole group (kill -TERM -- -$$). A signal that stops $$ ends the line with 128 plus the signal and leaves its jobs running. As in Bash, a shell ignores QUIT, which stops only the program it is running. A nested bash -c is a process of its own, with its own $$.
  • The shell’s own errors start as a non-interactive Bash’s do, bash: line N: , with environment in place of bash inside a function and the file’s path inside a sourced file or a script. $LINENO is the running command’s line and $BASHPID the process running it. When a signal ends a command, the shell prints Bash’s report line after it, such as bash: line 1: 12 Killed sleep 3; for a background job, after the next program, subshell or pipeline it runs, or at wait. TERM prints Terminated for a command and nothing for a job, and INT and PIPE print nothing. A program a runtime runs in the foreground is not a process of its own, so no report line follows when a signal ends it; its status is still 128 plus the signal. A command substitution reports nothing.
  • A program a sandbox runs, or one a host machine captures besides its own python3, writes its output and its stderr into a redirect’s file as it prints them. So do most of Mirage’s commands, such as cat, grep, awk, sed, tee, sort and jq, and the commands in a group, a loop or a function ({ echo a; sleep 9; } > f). A command that reads or changes that file meanwhile finds what was written before it, and cat and grep refuse to read the file their own output goes to, as GNU’s do. The output follows the file through a rename the line makes, and the rest is lost once the line removes it or renames another file over it, as in Bash; a rename made from another session or through FUSE is not followed. What a stopped command wrote stays in the file, whether kill, timeout or a cancelled call stopped it. Others, such as tar, gzip and a host machine’s python3, write theirs when they end, as do a program a Daytona sandbox runs and a microsandbox program given piped input. A file on a RAM mount shows a streaming write within a tenth of a second; an object store such as S3 publishes it when the write ends.
  • set and shopt recognize more option names than they implement; accepting or displaying an option does not mean every Bash behavior is available.
  • Enable extglob before the call that uses its syntax, or use eval after enabling it. A whole shell() call is parsed before it runs.
  • Command substitutions and background jobs do not inherit stdin. Writes through an already open output descriptor append rather than track a write offset.
  • Syntax errors return exit status 2. Compatibility is a supported subset of Bash, not a full Bash installation.