# Shell Operations Run any command or bash script in the build container. ## Operations ### Shell.Run Runs a command with arguments in the build container, in order with the other steps. Arguments are passed as a list with no shell parsing. Fails on a non-zero exit code unless AllowFailure(). Returns a CommandStep (Value, ExitCode, Json(path); fluent InDirectory, WithTimeout, WithEnv, AllowFailure, Quiet). Signature: Run(string command, params string[] args). This is the escape hatch for one-off commands that have no ANDO operation. Prefer a first-party operation (Dotnet.*, Npm.*, Http.Get, Git.* and so on) when one exists. ```csharp Shell.Run("zip", "-qr", "../web.zip", ".").InDirectory("artifacts/web"); ``` ### Shell.Bash Runs a script with bash -euo pipefail -c in the build container, for pipes, redirection and sourcing helper scripts. Returns a CommandStep. Signature: Bash(string script). ```csharp Shell.Bash("source scripts/lib/deploy-gates.sh && require_spa_build artifacts/web"); ``` ## Overview `Shell.Run` and `Shell.Bash` register a step that runs a command in the build container, in order with the other steps. They are the escape hatch for one-off commands that have no ANDO operation. When a first-party operation exists (`Dotnet.*`, `Npm.*`, `Http.Get`, `Git.*`, `Docker.Build` and so on), use it instead: it understands the tool's options, installs prerequisites and reports better errors. The step fails the build on a non-zero exit code unless you call `AllowFailure()`. Both return a `CommandStep`. Its output can be read at execution time by later steps (see the Ando provider page, "Step model"). Hook scripts have a different `Shell` global (`Shell.RunAsync`). The operations on this page are for `build.csando`. ## Example ```csharp // Use a helper script as a gate (zipping and copying have Archive.Zip and Files.Copy) Shell.Bash("source scripts/lib/deploy-gates.sh && require_spa_build artifacts/web"); // Read the output later, at execution time var version = Shell.Run("cat", "VERSION").Quiet(); Ando.Report("version", () => version.Value); ``` ## Notes - `Shell.Run` passes arguments as a list, with no shell parsing. Use `Shell.Bash` for pipes, redirection and sourcing scripts. - `Shell.Bash` runs `bash -euo pipefail -c