View on GitHub

🚀 run $command

Easily get / test the output of shell commands

download .ZIPdownload .TGZ

🚀 run $command

Simplest possible run command for beautiful shell script tests!



Download the latest version or install via:

curl -o- https://run.specs.sh/install.sh | bash

Source the downloaded run.sh script to use in your tests:

source "run.sh"

run echo "Hello, world"

echo "$STDOUT"
# => "Hello, world"

echo "$STDERR"
# => ""

echo "$EXITCODE"
# => "0"

run $command

$STDOUT

To get the standard output, check the $STDOUT variable:

run echo "Hello, world"

echo "$STDOUT"
# => Hello, world

$STDERR

To get the standard output, check the $STDERR variable:

run foo "This command does not exist"

echo "$STDERR"
# => foo: command not found

$EXITCODE

To get the standard output, check the $EXITCODE variable:

run echo "Hello, world"

echo $EXITCODE
# => 0
run foo "This command does not exist"

echo $EXITCODE
# => 127

{ Current Shell } or {{ Subshell }}

To run a function or command in the current shell:

Alternatively, to run a function or command in the current shell:

To run a function or command in a subshell:

ℹī¸ Subshells

Commands run inside subshells have access to all local variables but changes are not reflected in the outer shell:

run supports both braces and brackets to support commands which use brackets or braces as arguments.

To call the [ shell builtin function, you must wrap the command in braces: run { [ 1 -eq 2 ] }