bash
The bash spell lints shell scripts. Its single op finds every .sh/.bash file and runs shellcheck over the set.
Runtime name: bash (source spells/bash/)
Version probe: none
Passing arguments to ops
Every op is invoked as bash["<op>"](ctx, opts?). The first argument is the target's context, which is what carries the execution environment; the optional options map shapes the command itself:
| Key | Type | Description | Source |
|---|---|---|---|
args |
[str] |
Extra arguments appended to the resolved command, replacing any trailing defaults the op declares (go-test's ./...), so passing args also states the scope. Omit it and a bare bash["<op>"]() keeps the defaults and forwards magus run <target> -- <extra> to the tool automatically; pass it to set the arguments explicitly, which replaces that passthrough. |
source |
stdin |
str |
Data written to the command's standard input. | source |
Working directory and environment are NOT options: they ride the context, as bash["<op>"](ctx.withCwd("sub")) and bash["<op>"](ctx.withEnv({"CGO_ENABLED": "0"})). Only the context reaches the cache key, so an option-table cwd or env would change what the tool did while the key said otherwise; passing either as an option is an error.
Charms (the :charm suffix, e.g. magus run test:rw) are orthogonal: they patch the base argv, while these options add to it. See Charms.
shellcheck
One shellcheck invocation over every shell source. sources is the engine-side replacement for the sh -c "find ... | xargs ..." this op used to run: the runner expands the globs into a file list per project - the same walk that builds the cache key - honoring mgs_listIgnoreDirs above and the workspace's own ignore dirs, and appends the matches to argv. Batched (the default, sourcesEach unset) puts every match across as few shellcheck invocations as fit under the runner's ARG_MAX-safe limit; a glob set that matches nothing runs shellcheck zero times rather than failing (mirrors xargs -r).
Command: shellcheck
Example
// shellcheck lints every .sh/.bash script found under the project.
import "magus";
import "magus/spell/bash";
magus\project({ "spells": [bash] });
export fun lint(ctx: magus\Context, args: [str]) > void {
bash["shellcheck"](ctx);
}