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 sameworkspace_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:
$!, kill, wait and
ps -p take either kind.
Per-session mount modes
Session mount modes can narrow access toread, 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 -tvalues are accepted but do not enforce a timeout. bg,complete,compgen,ulimit,coproc, andexec -a/-lare not implemented.- A process substitution’s
/dev/fd/Npath 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 withexec 3> >(command)fails with exit status2. - There is no interactive terminal or OS process job control. The supported job commands manage Mirage jobs:
cmd &,jobs,waitandkill. killtakes every Linux signalkill -llists, by name or number.STOPpauses a job, whichpsshows asT, andCONTlets it go on; aTERMsent meanwhile waits for theCONT. A Mirage command pauses at its next file operation, pipe write, sleep or loop turn, and in a browserSTOPof 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.KILLis sent only forkill -9,timeout -k, or when the workspace shuts down. Any other process stops, andwaitreports 128 plus the signal, as in Bash. As in Bash, a background job ignoresINTandQUIT. Unlike Bash,killalso stops the jobs a job started and theirs, even once the job between them has ended.- When time runs out,
timeoutsignals its command’s process group, as GNUtimeoutdoes, so the jobs the command started stop too. It doesn’t with--foreground,-s INTor-s QUIT. - A background job that gets
INTacts 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 ignoresQUIT, which stops only the program it is running. A nestedbash -cis a process of its own, with its own$$. - The shell’s own errors start as a non-interactive Bash’s do,
bash: line N:, withenvironmentin place ofbashinside a function and the file’s path inside a sourced file or a script.$LINENOis the running command’s line and$BASHPIDthe process running it. When a signal ends a command, the shell prints Bash’s report line after it, such asbash: line 1: 12 Killed sleep 3; for a background job, after the next program, subshell or pipeline it runs, or atwait.TERMprintsTerminatedfor a command and nothing for a job, andINTandPIPEprint 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
hostmachine captures besides its ownpython3, writes its output and its stderr into a redirect’s file as it prints them. So do most of Mirage’s commands, such ascat,grep,awk,sed,tee,sortandjq, 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, andcatandgreprefuse 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, whetherkill,timeoutor a cancelled call stopped it. Others, such astar,gzipand ahostmachine’spython3, 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. setandshoptrecognize more option names than they implement; accepting or displaying an option does not mean every Bash behavior is available.- Enable
extglobbefore the call that uses its syntax, or useevalafter enabling it. A wholeshell()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.