Skip to navigation

Run shell command (detailed)

Referenced In

Fields

Validation applies the defaults shown here.

FieldTypeDescriptionDefault
commandstringRequired. Command to perform in the selected shell (see shell; defaults to bash on every platform).—
shellstringOptional. Shell to run the command in. If unset, uses the config-level shell setting, which defaults to bash. cmd and powershell are only supported on Windows. On Windows, bash resolves to Git Bash, which Doc Detective installs automatically if it isn’t present.

Accepted values: bash, cmd, powershell
—
argsarray of stringOptional. Arguments for the command.[]
workingDirectorystringOptional. Folder to run the command in. Omit to run in the folder you ran Doc Detective from. A relative path resolves against the spec file, so . is the spec’s folder. When relativePathBase is cwd, it resolves against the current directory instead.—
exitCodesarray of integerOptional. Expected exit codes of the command. If the command’s actual exit code isn’t in this list, the step fails.[0]
stdiostringOptional. Content expected in the command’s stdout or stderr. If the expected content can’t be found in the command’s stdout or stderr, the step fails. Supports strings and regular expressions. To use a regular expression, the string must start and end with a forward slash, like in /^hello-world.*/.—
pathstringOptional. File path to save the command’s output, relative to directory.—
directorystringOptional. Folder that path is relative to. Doc Detective creates it if it doesn’t exist. Omit to resolve path against the spec file, or against the current directory when relativePathBase is cwd.—
maxVariationnumberOptional. Allowed variation as a fraction (0 to 1) of text different between the current output and previously saved output. For example, 0.1 means 10%. If the difference between the current output and the previous output is greater than maxVariation, the step returns a warning. If output doesn’t exist at path, this value is ignored.

Minimum: 0. Maximum: 1
0
overwritestringOptional. If true, overwrites the existing output at path if it exists.
If aboveVariation, overwrites the existing output at path if the difference between the new output and the existing output is greater than maxVariation.

Accepted values: true, false, aboveVariation
aboveVariation
timeoutintegerOptional. Max time in milliseconds the command is allowed to run. If the command runs longer than this, the step fails. When background is set, this is instead the max time to wait for background.waitUntil to be satisfied before the step fails.

Minimum: 1
60000
backgroundobjectOptional. Start the command as a long-running background process and return as soon as it is ready, instead of waiting for it to exit. When set, exitCodes, stdio, and output saving (path, directory, maxVariation, overwrite) are ignored, and timeout is the max time to wait for waitUntil. The process is owned by the run and is stopped by a closeSurface step or automatically when the run finishes.—

Examples

{
"command": "example",
"shell": "bash",
"args": [],
"workingDirectory": "example",
"exitCodes": [
0
],
"stdio": "example",
"path": "example",
"directory": "example",
"maxVariation": 0,
"overwrite": "aboveVariation",
"timeout": 60000,
"background": {
"name": "example"
}
}