#599

Infinity execution limits make every glob and pattern substitution fail (exit 126)

Openasafyishopened 15d ago

just-bash version

3.6.0

Reproduction

import { Bash } from "just-bash";

const bash = new Bash({
  executionLimits: { maxGlobOperations: Infinity },
  files: { "/data/a.txt": "a", "/data/b.txt": "b" },
});

console.log(await bash.exec("echo /data/*.txt"));
console.log(await bash.exec("v=a-b; echo ${v//-/+}"));

Expected behavior

Either Infinity lifts the limit, so the commands print /data/a.txt /data/b.txt and a+b as they do with the default limits, or the Bash constructor rejects the value with an error that names the field.

ExecutionLimits fields are typed number and the docs only say that undefined values use the defaults, so Infinity reads as a supported way to lift a limit.

Actual behavior

The constructor accepts it, and the first glob or pattern substitution fails as though it were a shell error:

exit 126  bash: glob expansion: glob_operations work limit exceeded (Infinity)
exit 126  bash: pattern replacement: pattern_operations work limit exceeded (Infinity)

The counters checked through consumeLimited require Number.isSafeInteger(limit), while consume() (commands, aggregate work units) accepts Infinity, so only some limits break, and only once something uses them. Number.MAX_SAFE_INTEGER works as a workaround.

Environment

  • Runtime: Node 26 (Linux and macOS)
  • new Bash({ executionLimits, fs }) with a custom IFileSystem; the reproduction above uses the default in-memory filesystem.

Activity

0

No activity yet.