diff --git a/README.md b/README.md index 5accc82..37ab576 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,7 @@ console.log(`Hello from ${$.blue.bold("worker")}!`); - **$.shell:** Set the shell that is used by `` $`command` ``. Default: `/bin/sh` +- **$.prefix:** Command prefix. Default: `set -euo pipefail;`. - **$.mainModule:** The executed dzx script. - **$.verbose:** Enable debugging output (log shell commands and execution time). diff --git a/src/runtime/exec.ts b/src/runtime/exec.ts index fb36293..47ba5f5 100644 --- a/src/runtime/exec.ts +++ b/src/runtime/exec.ts @@ -19,7 +19,7 @@ export async function exec( const stderr: Array = []; const combined: Array = []; const process = Deno.run({ - cmd: [$.shell, "-c", cmd], + cmd: [$.shell, "-c", $.prefix + " " + cmd], env: Deno.env.toObject(), stdout: $.stdout, stderr: $.stderr, diff --git a/src/runtime/mod.ts b/src/runtime/mod.ts index 1732c03..a936370 100644 --- a/src/runtime/mod.ts +++ b/src/runtime/mod.ts @@ -5,6 +5,7 @@ import { quote } from "./quote.ts"; export type $ = typeof exec & typeof colors & { shell: string; + prefix: string; mainModule: string; verbose: boolean; stdout: NonNullable; @@ -22,6 +23,7 @@ Object.setPrototypeOf($, Object.getPrototypeOf(colors)); $._stack = []; $.shell = "/bin/sh"; +$.prefix = "set -euo pipefail;"; $.mainModule = ""; $.verbose = false; $.stdout = "piped";