Skip to main content

Module protocol

Module protocol 

Source
Expand description

The directive protocol: how the binary changes the state of the wrapped shell.

A process cannot change the working directory or the environment of its parent. Instead the binary writes directives to its own stderr, and the shellgame shell function (bash.sh, fish.fish) replays them in the player’s shell after the binary has exited.

__SHELLGAME_EXEC__v1 <verb>[ <base64 argument>...]
verbargumentseffect in the shell
cddestinationchange directory, bypassing the player-facing cd
exportname, valueset and export one variable (^[A-Za-z_][A-Za-z0-9_]*$)
echomessageprint one line
pwdnoneprint the working directory
exitnoneclose the game shell

Every argument is standard, padded base64 of the raw bytes, so spaces and shell metacharacters never reach a shell parser. Lines end in LF. Unknown versions, verbs and argument counts are ignored by the shell, and there is no way to run arbitrary commands.

Directives is the typed emitter used by the game; encode is the pure encoder behind it.

Structs§

Directives
Emits directives for the wrapper shell, or does nothing when the binary runs outside of it.
InvalidName
An environment variable name that the shell would refuse to export.

Constants§

PREFIX
Marker that starts every directive line. Anything else on stderr is plain output.
VERSION
Protocol version, written right after PREFIX.

Functions§

encode
Encodes one directive line, without the trailing newline.