shfs 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-CsIHQwCC.mjs","names":["normalizeOptions","ROOT_DIRECTORY","formatRecord","MULTIPLE_SLASH_REGEX","ROOT_DIRECTORY","TRAILING_SLASH_REGEX","formatRecord","toRelativePathFromCwd","formatShellRecord","VARIABLE_NAME_REGEX","TRAILING_SLASH_REGEX","MULTIPLE_SLASH_REGEX","trimTrailingSlash","joinPath","basename","isDirectory","basename","basename","trimTrailingSlash","ROOT_DIRECTORY"],"sources":["../../compiler/dist/index.mjs","../src/record.ts","../src/execute/path.ts","../src/builtin/cd/cd.ts","../src/builtin/echo/echo.ts","../src/execute/records.ts","../src/builtin/read/read.ts","../src/builtin/set/set.ts","../src/builtin/string/string.ts","../src/builtin/test/test.ts","../src/operator/cat/cat.ts","../src/operator/cp/cp.ts","../src/operator/find/find.ts","../src/execute/redirection.ts","../src/operator/grep/grep.ts","../src/operator/head/head.ts","../src/operator/ls/ls.ts","../src/operator/mkdir/mkdir.ts","../src/operator/mv/mv.ts","../src/operator/pwd/pwd.ts","../src/operator/rm/rm.ts","../src/operator/tail/tail.ts","../src/operator/touch/touch.ts","../src/execute/producers.ts","../src/execute/execute.ts"],"sourcesContent":["//#region src/ir.ts\n/**\n* Create a literal ExpandedWord.\n*/\nfunction literal(value) {\n\treturn {\n\t\tkind: \"literal\",\n\t\tvalue\n\t};\n}\n/**\n* Create a compound ExpandedWord that preserves ordered parts.\n*/\nfunction compound(parts) {\n\treturn {\n\t\tkind: \"compound\",\n\t\tparts\n\t};\n}\n/**\n* Create a SimpleCommandIR for testing purposes.\n* Convenience helper that creates a command with a name and arguments.\n*/\nfunction cmd(name, args, redirections = []) {\n\treturn {\n\t\tname: literal(name),\n\t\targs,\n\t\tredirections\n\t};\n}\n/**\n* Create a glob ExpandedWord.\n*/\nfunction glob(pattern, expanded = []) {\n\treturn {\n\t\tkind: \"glob\",\n\t\tpattern,\n\t\texpanded\n\t};\n}\n/**\n* Create a command substitution ExpandedWord.\n*/\nfunction commandSub(command, output = []) {\n\treturn {\n\t\tkind: \"commandSub\",\n\t\tcommand,\n\t\toutput\n\t};\n}\n/**\n* Extract the string value from an ExpandedWord.\n* For globs, returns the pattern. For command subs, returns the command.\n*/\nfunction expandedWordToString(word) {\n\tswitch (word.kind) {\n\t\tcase \"literal\": return word.value;\n\t\tcase \"glob\": return word.pattern;\n\t\tcase \"commandSub\": return word.command;\n\t\tcase \"compound\": return word.parts.map(expandedWordPartToString).join(\"\");\n\t\tdefault: {\n\t\t\tconst _exhaustive = word;\n\t\t\tthrow new Error(`Unknown word kind: ${JSON.stringify(_exhaustive)}`);\n\t\t}\n\t}\n}\nfunction expandedWordParts(word) {\n\treturn word.kind === \"compound\" ? word.parts : [word];\n}\nfunction expandedWordHasGlob(word) {\n\treturn expandedWordParts(word).some((part) => part.kind === \"glob\");\n}\nfunction expandedWordHasCommandSub(word) {\n\treturn expandedWordParts(word).some((part) => part.kind === \"commandSub\");\n}\n/**\n* Extract paths from an array of ExpandedWords.\n* For globs and command subs, expands to their resolved values.\n*/\nfunction extractPathsFromExpandedWords(words) {\n\treturn words.flatMap((word) => {\n\t\tswitch (word.kind) {\n\t\t\tcase \"literal\": return [word.value];\n\t\t\tcase \"glob\": return word.expanded.length > 0 ? word.expanded : [word.pattern];\n\t\t\tcase \"commandSub\": return word.output;\n\t\t\tcase \"compound\": return [expandedWordToString(word)];\n\t\t\tdefault: {\n\t\t\t\tconst _exhaustive = word;\n\t\t\t\tthrow new Error(`Unknown word kind: ${JSON.stringify(_exhaustive)}`);\n\t\t\t}\n\t\t}\n\t});\n}\nfunction expandedWordPartToString(part) {\n\tswitch (part.kind) {\n\t\tcase \"literal\": return part.value;\n\t\tcase \"glob\": return part.pattern;\n\t\tcase \"commandSub\": return part.command;\n\t\tdefault: {\n\t\t\tconst _exhaustive = part;\n\t\t\tthrow new Error(`Unknown word part kind: ${JSON.stringify(_exhaustive)}`);\n\t\t}\n\t}\n}\n\n//#endregion\n//#region src/compile/command/arg/utils.ts\nconst NEGATIVE_NUMBER_REGEX = /^(?:-\\d+(?:\\.\\d+)?|-\\.\\d+)$/;\nfunction isNegativeNumberToken(token) {\n\treturn NEGATIVE_NUMBER_REGEX.test(token);\n}\nfunction startsWithLongPrefix(token) {\n\treturn token.length >= 2 && token[0] === \"-\" && token[1] === \"-\";\n}\nfunction startsWithShortPrefix(token) {\n\treturn token.length >= 1 && token[0] === \"-\" && !startsWithLongPrefix(token);\n}\nfunction startsWithNoLongPrefix(token) {\n\treturn token.startsWith(\"--no-\") && token.length > 5;\n}\nfunction splitNameBeforeEquals(token) {\n\tconst eq = token.indexOf(\"=\");\n\treturn eq === -1 ? token : token.slice(0, eq);\n}\n\n//#endregion\n//#region src/compile/command/arg/parse/diagnostics.ts\nconst UNKNOWN_FLAG_PREFIX$3 = \"Unknown flag: \";\nfunction createParseDiagnostic(code, token, tokenIndex, error) {\n\tlet message = \"Unknown parse error.\";\n\tif (error instanceof Error) message = error.message;\n\telse if (typeof error === \"string\") message = error;\n\treturn {\n\t\tcode,\n\t\tmessage,\n\t\ttoken,\n\t\ttokenIndex\n\t};\n}\nfunction throwUnknownFlag(token) {\n\tthrow new Error(`${UNKNOWN_FLAG_PREFIX$3}${token}`);\n}\nfunction isUnknownFlagError(error) {\n\tif (!(error instanceof Error)) return false;\n\treturn error.message.startsWith(UNKNOWN_FLAG_PREFIX$3);\n}\n\n//#endregion\n//#region src/compile/command/arg/parse/options.ts\nfunction normalizeOptions(options) {\n\treturn {\n\t\terrorPolicy: options?.errorPolicy ?? \"throw\",\n\t\tnegativeNumberPolicy: options?.negativeNumberPolicy ?? \"positional\",\n\t\tnegativeNumberFlag: options?.negativeNumberFlag,\n\t\tunknownFlagPolicy: options?.unknownFlagPolicy ?? \"error\"\n\t};\n}\nfunction getNegativeNumberValueEntry(options, index) {\n\tif (options.negativeNumberPolicy === \"positional\") return;\n\tif (!options.negativeNumberFlag) throw new Error(\"negativeNumberFlag is required when negativeNumberPolicy is \\\"value\\\".\");\n\tconst entry = index.canonical.get(options.negativeNumberFlag);\n\tif (!entry) throw new Error(`Unknown negativeNumberFlag: \"${options.negativeNumberFlag}\".`);\n\tif (!entry.def.takesValue) throw new Error(`negativeNumberFlag \"${options.negativeNumberFlag}\" must reference a flag that takes a value.`);\n\treturn entry;\n}\n\n//#endregion\n//#region src/compile/command/arg/parse/state.ts\nfunction appendPositional(positional, positionalIndices, token, index) {\n\tpositional.push(token);\n\tpositionalIndices.push(index);\n}\nfunction cloneFlags(source) {\n\tconst cloned = Object.create(null);\n\tfor (const [key, value] of Object.entries(source)) cloned[key] = Array.isArray(value) ? [...value] : value;\n\treturn cloned;\n}\nfunction cloneConsumedValueIndices(source) {\n\tconst cloned = Object.create(null);\n\tfor (const [key, value] of Object.entries(source)) cloned[key] = [...value];\n\treturn cloned;\n}\nfunction cloneConsumedValueSources(source) {\n\tconst cloned = Object.create(null);\n\tfor (const [key, value] of Object.entries(source)) cloned[key] = [...value];\n\treturn cloned;\n}\nfunction cloneFlagOccurrenceOrder(source) {\n\tconst cloned = Object.create(null);\n\tfor (const [key, value] of Object.entries(source)) cloned[key] = [...value];\n\treturn cloned;\n}\nfunction setBoolean(out, flagOccurrenceOrder, orderState, canonical, value) {\n\tout[canonical] = value;\n\trecordFlagOccurrence(flagOccurrenceOrder, canonical, orderState.nextFlagOrder);\n\torderState.nextFlagOrder += 1;\n}\nfunction setValue(out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState, entry, value, valueIndex, valueSource) {\n\tconst { canonical, def } = entry;\n\tconst recordValueUsage = () => {\n\t\trecordConsumedValueIndex(consumedValueIndices, canonical, valueIndex);\n\t\trecordConsumedValueSource(consumedValueSources, canonical, valueSource);\n\t\trecordFlagOccurrence(flagOccurrenceOrder, canonical, orderState.nextFlagOrder);\n\t\torderState.nextFlagOrder += 1;\n\t};\n\tconst existing = out[canonical];\n\tif (existing === void 0) {\n\t\tout[canonical] = value;\n\t\trecordValueUsage();\n\t\treturn;\n\t}\n\tif (!def.multiple) throw new Error(`Duplicate flag \"${canonical}\". If it is intended to repeat, set { multiple: true } in its definition.`);\n\tif (Array.isArray(existing)) {\n\t\texisting.push(value);\n\t\trecordValueUsage();\n\t\treturn;\n\t}\n\tif (typeof existing === \"string\") {\n\t\tout[canonical] = [existing, value];\n\t\trecordValueUsage();\n\t\treturn;\n\t}\n\tthrow new Error(`Invalid state for flag \"${canonical}\".`);\n}\nfunction recordConsumedValueIndex(consumedValueIndices, canonical, valueIndex) {\n\tconst existing = consumedValueIndices[canonical];\n\tif (!existing) {\n\t\tconsumedValueIndices[canonical] = [valueIndex];\n\t\treturn;\n\t}\n\texisting.push(valueIndex);\n}\nfunction recordConsumedValueSource(consumedValueSources, canonical, valueSource) {\n\tconst existing = consumedValueSources[canonical];\n\tif (!existing) {\n\t\tconsumedValueSources[canonical] = [valueSource];\n\t\treturn;\n\t}\n\texisting.push(valueSource);\n}\nfunction recordFlagOccurrence(flagOccurrenceOrder, canonical, order) {\n\tconst existing = flagOccurrenceOrder[canonical];\n\tif (!existing) {\n\t\tflagOccurrenceOrder[canonical] = [order];\n\t\treturn;\n\t}\n\texisting.push(order);\n}\n\n//#endregion\n//#region src/compile/command/arg/parse/token/value.ts\nfunction consumeValue(args, index, flagToken, flagsIndex, entry) {\n\tconst nextIndex = index + 1;\n\tif (nextIndex >= args.length) throw new Error(`Flag ${flagToken} requires a value.`);\n\tconst next = args[nextIndex];\n\tif (next === void 0) throw new Error(`Flag ${flagToken} requires a value.`);\n\tif (next === \"--\") throw new Error(`Flag ${flagToken} requires a value (got \"--\").`);\n\tif (!entry.def.allowFlagLikeValue && flagsIndex.isFlagToken(next)) throw new Error(`Flag ${flagToken} requires a value (got \"${next}\").`);\n\treturn {\n\t\tvalue: next,\n\t\tnewIndex: nextIndex,\n\t\tvalueIndex: nextIndex\n\t};\n}\n\n//#endregion\n//#region src/compile/command/arg/parse/token/long.ts\nconst parseLongToken = (args, index, token, flagsIndex, out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState) => {\n\tif (startsWithNoLongPrefix(token) && !token.includes(\"=\")) {\n\t\tconst base = `--${token.slice(5)}`;\n\t\tconst entry = flagsIndex.long.get(base);\n\t\tif (!entry) throwUnknownFlag(token);\n\t\tif (entry.def.takesValue) throw new Error(`Flag ${base} takes a value; \"${token}\" is invalid.`);\n\t\tsetBoolean(out, flagOccurrenceOrder, orderState, entry.canonical, false);\n\t\treturn index;\n\t}\n\tif (token.includes(\"=\")) {\n\t\tconst eq = token.indexOf(\"=\");\n\t\tconst name = token.slice(0, eq);\n\t\tconst value = token.slice(eq + 1);\n\t\tconst entry = flagsIndex.long.get(name);\n\t\tif (!entry) throwUnknownFlag(name);\n\t\tif (!entry.def.takesValue) throw new Error(`Flag ${name} does not take a value.`);\n\t\tsetValue(out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState, entry, value, index, \"inline\");\n\t\treturn index;\n\t}\n\tconst entry = flagsIndex.long.get(token);\n\tif (!entry) throwUnknownFlag(token);\n\tif (!entry.def.takesValue) {\n\t\tsetBoolean(out, flagOccurrenceOrder, orderState, entry.canonical, true);\n\t\treturn index;\n\t}\n\tconst { newIndex, value, valueIndex } = consumeValue(args, index, token, flagsIndex, entry);\n\tsetValue(out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState, entry, value, valueIndex, \"arg\");\n\treturn newIndex;\n};\n\n//#endregion\n//#region src/compile/command/arg/parse/flag-index.ts\nconst SHORT_NAME_REGEX = /^[A-Za-z]$/;\nconst LONG_NAME_REGEX = /^[A-Za-z0-9][A-Za-z0-9-]*$/;\nfunction buildFlagIndex(flagDefs) {\n\tconst canonical = /* @__PURE__ */ new Map();\n\tconst short = /* @__PURE__ */ new Map();\n\tconst long = /* @__PURE__ */ new Map();\n\tconst add = (map, token, entry) => {\n\t\tconst prev = map.get(token);\n\t\tif (!prev) {\n\t\t\tmap.set(token, entry);\n\t\t\treturn;\n\t\t}\n\t\tthrow new Error(`Duplicate flag token \"${token}\" for \"${entry.canonical}\" and \"${prev.canonical}\"`);\n\t};\n\tfor (const [canonicalName, def] of Object.entries(flagDefs)) {\n\t\tif (!(def.short || def.long)) throw new Error(`Flag \"${canonicalName}\" must define at least one of \"short\" or \"long\".`);\n\t\tconst entry = {\n\t\t\tcanonical: canonicalName,\n\t\t\tdef\n\t\t};\n\t\tcanonical.set(canonicalName, entry);\n\t\tif (def.short !== void 0) {\n\t\t\tif (!SHORT_NAME_REGEX.test(def.short)) throw new Error(`Invalid short flag for \"${canonicalName}\": \"${def.short}\". Expected a single letter [A-Za-z].`);\n\t\t\tadd(short, `-${def.short}`, entry);\n\t\t}\n\t\tif (def.long) {\n\t\t\tif (!LONG_NAME_REGEX.test(def.long)) throw new Error(`Invalid long flag for \"${canonicalName}\": \"${def.long}\". Expected [A-Za-z0-9][A-Za-z0-9-]*.`);\n\t\t\tadd(long, `--${def.long}`, entry);\n\t\t}\n\t}\n\tconst isFlagToken = (token) => {\n\t\tif (token === \"--\") return true;\n\t\tif (token === \"-\") return false;\n\t\tif (startsWithLongPrefix(token)) {\n\t\t\tconst name = splitNameBeforeEquals(token);\n\t\t\tif (long.has(name)) return true;\n\t\t\tif (startsWithNoLongPrefix(name)) {\n\t\t\t\tconst base = `--${name.slice(5)}`;\n\t\t\t\tconst entry = long.get(base);\n\t\t\t\treturn !!entry && !entry.def.takesValue;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\tif (startsWithShortPrefix(token)) {\n\t\t\tconst ch = token[1] ?? \"\";\n\t\t\tif (!SHORT_NAME_REGEX.test(ch)) return false;\n\t\t\treturn short.has(`-${ch}`);\n\t\t}\n\t\treturn false;\n\t};\n\treturn {\n\t\tcanonical,\n\t\tshort,\n\t\tlong,\n\t\tisFlagToken\n\t};\n}\nfunction isShortFlagCharacter(ch) {\n\treturn SHORT_NAME_REGEX.test(ch);\n}\n\n//#endregion\n//#region src/compile/command/arg/parse/token/short.ts\nconst parseShortToken = (args, index, token, flagsIndex, out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState) => {\n\tif (token.length >= 3 && token[2] === \"=\") return parseShortEqualsToken(index, token, flagsIndex, out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState);\n\tif (token.length === 2) return parseSingleShortToken(args, index, token, flagsIndex, out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState);\n\treturn parseShortClusterToken(args, index, token, flagsIndex, out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState);\n};\nfunction parseShortEqualsToken(index, token, flagsIndex, out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState) {\n\tconst name = token.slice(0, 2);\n\tconst value = token.slice(3);\n\tconst entry = getRequiredShortEntry(flagsIndex, name);\n\tassertTakesValue(entry, name);\n\tsetValue(out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState, entry, value, index, \"inline\");\n\treturn index;\n}\nfunction parseSingleShortToken(args, index, token, flagsIndex, out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState) {\n\tconst entry = getRequiredShortEntry(flagsIndex, token);\n\tif (!entry.def.takesValue) {\n\t\tsetBoolean(out, flagOccurrenceOrder, orderState, entry.canonical, true);\n\t\treturn index;\n\t}\n\tconst { newIndex, value, valueIndex } = consumeValue(args, index, token, flagsIndex, entry);\n\tsetValue(out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState, entry, value, valueIndex, \"arg\");\n\treturn newIndex;\n}\nfunction parseShortClusterToken(args, index, token, flagsIndex, out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState) {\n\tfor (let j = 1; j < token.length; j++) {\n\t\tconst ch = token[j] ?? \"\";\n\t\tassertValidShortCharacter(token, ch);\n\t\tconst name = `-${ch}`;\n\t\tconst entry = getRequiredShortEntry(flagsIndex, name);\n\t\tif (!entry.def.takesValue) {\n\t\t\tsetBoolean(out, flagOccurrenceOrder, orderState, entry.canonical, true);\n\t\t\tcontinue;\n\t\t}\n\t\treturn parseValueFlagInShortCluster(args, index, token, j, name, entry, flagsIndex, out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState);\n\t}\n\treturn index;\n}\nfunction parseValueFlagInShortCluster(args, index, token, flagPosition, name, entry, flagsIndex, out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState) {\n\tconst rest = token.slice(flagPosition + 1);\n\tif (rest.startsWith(\"=\")) {\n\t\tsetValue(out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState, entry, rest.slice(1), index, \"inline\");\n\t\treturn index;\n\t}\n\tif (rest.length === 0) {\n\t\tconst { newIndex, value, valueIndex } = consumeValue(args, index, name, flagsIndex, entry);\n\t\tsetValue(out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState, entry, value, valueIndex, \"arg\");\n\t\treturn newIndex;\n\t}\n\tassertNotAmbiguousShortValue(token, name, rest, flagsIndex, entry);\n\tsetValue(out, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState, entry, rest, index, \"inline\");\n\treturn index;\n}\nfunction getRequiredShortEntry(flagsIndex, name) {\n\tconst entry = flagsIndex.short.get(name);\n\tif (!entry) throwUnknownFlag(name);\n\treturn entry;\n}\nfunction assertValidShortCharacter(token, ch) {\n\tif (isShortFlagCharacter(ch)) return;\n\tthrow new Error(`Invalid short flag character \"${ch}\" in \"${token}\". Short flags must be letters.`);\n}\nfunction assertTakesValue(entry, token) {\n\tif (entry.def.takesValue) return;\n\tthrow new Error(`Flag ${token} does not take a value.`);\n}\nfunction assertNotAmbiguousShortValue(token, name, rest, flagsIndex, entry) {\n\tif (entry.def.ambiguousShortValuePolicy === \"value\") return;\n\tconst first = rest[0] ?? \"\";\n\tif (!(isShortFlagCharacter(first) && flagsIndex.short.has(`-${first}`))) return;\n\tthrow new Error(`Ambiguous short flag cluster \"${token}\": ${name} takes a value, but \"${rest}\" begins with \"-${first}\" which is also a flag. Use \"${name}=${rest}\" or pass the value as a separate argument.`);\n}\n\n//#endregion\n//#region src/compile/command/arg/parse/engine.ts\nfunction parseArgsWithIndex(args, index, options) {\n\tconst normalizedOptions = normalizeOptions(options);\n\tconst negativeNumberValueEntry = getNegativeNumberValueEntry(normalizedOptions, index);\n\tlet consumedValueIndices = Object.create(null);\n\tlet consumedValueSources = Object.create(null);\n\tconst diagnostics = [];\n\tlet flagOccurrenceOrder = Object.create(null);\n\tlet flags = Object.create(null);\n\tconst positional = [];\n\tconst positionalIndices = [];\n\tlet nextFlagOrder = 0;\n\tlet endOfFlags = false;\n\tfor (let i = 0; i < args.length; i++) {\n\t\tconst token = args[i];\n\t\tif (token === void 0) continue;\n\t\ttry {\n\t\t\tconst result = processToken({\n\t\t\t\targs,\n\t\t\t\tconsumedValueIndices,\n\t\t\t\tconsumedValueSources,\n\t\t\t\tdiagnostics,\n\t\t\t\tendOfFlags,\n\t\t\t\tflagOccurrenceOrder,\n\t\t\t\tflags,\n\t\t\t\tflagsIndex: index,\n\t\t\t\tindex: i,\n\t\t\t\tnegativeNumberValueEntry,\n\t\t\t\tnextFlagOrder,\n\t\t\t\tpositional,\n\t\t\t\tpositionalIndices,\n\t\t\t\tsafeParseErrors: normalizedOptions.errorPolicy === \"diagnostic\",\n\t\t\t\ttoken,\n\t\t\t\tunknownFlagPolicy: normalizedOptions.unknownFlagPolicy\n\t\t\t});\n\t\t\tconsumedValueIndices = result.consumedValueIndices;\n\t\t\tconsumedValueSources = result.consumedValueSources;\n\t\t\tendOfFlags = result.endOfFlags;\n\t\t\tflagOccurrenceOrder = result.flagOccurrenceOrder;\n\t\t\tflags = result.flags;\n\t\t\ti = result.newIndex;\n\t\t\tnextFlagOrder = result.nextFlagOrder;\n\t\t} catch (error) {\n\t\t\tif (normalizedOptions.errorPolicy !== \"diagnostic\") throw error;\n\t\t\tdiagnostics.push(createParseDiagnostic(\"parse-error\", token, i, error));\n\t\t}\n\t}\n\treturn {\n\t\tconsumedValueIndices,\n\t\tconsumedValueSources,\n\t\tdiagnostics,\n\t\tflagOccurrenceOrder,\n\t\tflags,\n\t\tpositional,\n\t\tpositionalIndices\n\t};\n}\nfunction processToken(params) {\n\tconst { args, consumedValueIndices, consumedValueSources, diagnostics, endOfFlags, flagOccurrenceOrder, flags, flagsIndex, index, negativeNumberValueEntry, nextFlagOrder, positional, positionalIndices, safeParseErrors, token, unknownFlagPolicy } = params;\n\tif (endOfFlags || token === \"-\") {\n\t\tappendPositional(positional, positionalIndices, token, index);\n\t\treturn {\n\t\t\tconsumedValueIndices,\n\t\t\tconsumedValueSources,\n\t\t\tendOfFlags,\n\t\t\tflagOccurrenceOrder,\n\t\t\tflags,\n\t\t\tnewIndex: index,\n\t\t\tnextFlagOrder\n\t\t};\n\t}\n\tif (token === \"--\") return {\n\t\tconsumedValueIndices,\n\t\tconsumedValueSources,\n\t\tendOfFlags: true,\n\t\tflagOccurrenceOrder,\n\t\tflags,\n\t\tnewIndex: index,\n\t\tnextFlagOrder\n\t};\n\tif (isNegativeNumberToken(token)) {\n\t\tif (!negativeNumberValueEntry) {\n\t\t\tappendPositional(positional, positionalIndices, token, index);\n\t\t\treturn {\n\t\t\t\tconsumedValueIndices,\n\t\t\t\tconsumedValueSources,\n\t\t\t\tendOfFlags,\n\t\t\t\tflagOccurrenceOrder,\n\t\t\t\tflags,\n\t\t\t\tnewIndex: index,\n\t\t\t\tnextFlagOrder\n\t\t\t};\n\t\t}\n\t\tconst orderState = { nextFlagOrder };\n\t\tsetValue(flags, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, orderState, negativeNumberValueEntry, token.slice(1), index, \"inline\");\n\t\treturn {\n\t\t\tconsumedValueIndices,\n\t\t\tconsumedValueSources,\n\t\t\tendOfFlags,\n\t\t\tflagOccurrenceOrder,\n\t\t\tflags,\n\t\t\tnewIndex: index,\n\t\t\tnextFlagOrder: orderState.nextFlagOrder\n\t\t};\n\t}\n\tconst parser = getTokenParser(token);\n\tif (!parser) {\n\t\tappendPositional(positional, positionalIndices, token, index);\n\t\treturn {\n\t\t\tconsumedValueIndices,\n\t\t\tconsumedValueSources,\n\t\t\tendOfFlags,\n\t\t\tflagOccurrenceOrder,\n\t\t\tflags,\n\t\t\tnewIndex: index,\n\t\t\tnextFlagOrder\n\t\t};\n\t}\n\tconst parsed = parsePotentialFlagToken(args, index, token, flagsIndex, flags, consumedValueIndices, consumedValueSources, flagOccurrenceOrder, nextFlagOrder, safeParseErrors, unknownFlagPolicy, parser);\n\tif (!parsed) {\n\t\tif (unknownFlagPolicy === \"diagnostic\") diagnostics.push(createParseDiagnostic(\"unknown-flag\", token, index, token));\n\t\thandleUnrecognizedToken(unknownFlagPolicy, positional, positionalIndices, token, index);\n\t\treturn {\n\t\t\tconsumedValueIndices,\n\t\t\tconsumedValueSources,\n\t\t\tendOfFlags,\n\t\t\tflagOccurrenceOrder,\n\t\t\tflags,\n\t\t\tnewIndex: index,\n\t\t\tnextFlagOrder\n\t\t};\n\t}\n\treturn {\n\t\tconsumedValueIndices: parsed.consumedValueIndices,\n\t\tconsumedValueSources: parsed.consumedValueSources,\n\t\tendOfFlags,\n\t\tflagOccurrenceOrder: parsed.flagOccurrenceOrder,\n\t\tflags: parsed.flags,\n\t\tnewIndex: parsed.newIndex,\n\t\tnextFlagOrder: parsed.nextFlagOrder\n\t};\n}\nfunction getTokenParser(token) {\n\tif (startsWithLongPrefix(token)) return parseLongToken;\n\tif (startsWithShortPrefix(token)) return parseShortToken;\n}\nfunction parsePotentialFlagToken(args, index, token, flagsIndex, currentFlags, currentConsumedValueIndices, currentConsumedValueSources, currentFlagOccurrenceOrder, currentNextFlagOrder, safeParseErrors, unknownFlagPolicy, parser) {\n\tif (!(safeParseErrors || unknownFlagPolicy !== \"error\")) {\n\t\tconst orderState = { nextFlagOrder: currentNextFlagOrder };\n\t\treturn {\n\t\t\tconsumedValueIndices: currentConsumedValueIndices,\n\t\t\tconsumedValueSources: currentConsumedValueSources,\n\t\t\tflagOccurrenceOrder: currentFlagOccurrenceOrder,\n\t\t\tflags: currentFlags,\n\t\t\tnewIndex: parser(args, index, token, flagsIndex, currentFlags, currentConsumedValueIndices, currentConsumedValueSources, currentFlagOccurrenceOrder, orderState),\n\t\t\tnextFlagOrder: orderState.nextFlagOrder\n\t\t};\n\t}\n\tconst candidateFlags = cloneFlags(currentFlags);\n\tconst candidateConsumedValueIndices = cloneConsumedValueIndices(currentConsumedValueIndices);\n\tconst candidateConsumedValueSources = cloneConsumedValueSources(currentConsumedValueSources);\n\tconst candidateFlagOccurrenceOrder = cloneFlagOccurrenceOrder(currentFlagOccurrenceOrder);\n\tconst orderState = { nextFlagOrder: currentNextFlagOrder };\n\ttry {\n\t\treturn {\n\t\t\tconsumedValueIndices: candidateConsumedValueIndices,\n\t\t\tconsumedValueSources: candidateConsumedValueSources,\n\t\t\tflagOccurrenceOrder: candidateFlagOccurrenceOrder,\n\t\t\tflags: candidateFlags,\n\t\t\tnewIndex: parser(args, index, token, flagsIndex, candidateFlags, candidateConsumedValueIndices, candidateConsumedValueSources, candidateFlagOccurrenceOrder, orderState),\n\t\t\tnextFlagOrder: orderState.nextFlagOrder\n\t\t};\n\t} catch (error) {\n\t\tif (isUnknownFlagError(error) && unknownFlagPolicy !== \"error\") return null;\n\t\tthrow error;\n\t}\n}\nfunction handleUnrecognizedToken(policy, positional, positionalIndices, token, index) {\n\tif (policy === \"positional\") appendPositional(positional, positionalIndices, token, index);\n}\n\n//#endregion\n//#region src/compile/command/arg/parse.ts\nfunction createArgParser(flagDefs) {\n\tconst index = buildFlagIndex(flagDefs);\n\treturn (args, options) => {\n\t\treturn parseArgsWithIndex(args, index, options);\n\t};\n}\nfunction createWordParser(flagDefs, wordToString) {\n\tconst parseWithIndex = createArgParser(flagDefs);\n\treturn (words, options) => {\n\t\tconst parsed = parseWithIndex(words.map(wordToString), options);\n\t\tconst positionalWords = parsed.positionalIndices.flatMap((index) => {\n\t\t\tconst word = words[index];\n\t\t\treturn word === void 0 ? [] : [word];\n\t\t});\n\t\treturn {\n\t\t\t...parsed,\n\t\t\tpositionalWords\n\t\t};\n\t};\n}\n\n//#endregion\n//#region src/compile/command/cat/cat.ts\n/**\n* cat command handler for the AST-based compiler.\n*/\nconst parseCatArgs = createArgParser({\n\tnumber: {\n\t\tshort: \"n\",\n\t\ttakesValue: false\n\t},\n\tnumberNonBlank: {\n\t\tshort: \"b\",\n\t\ttakesValue: false\n\t},\n\tshowAll: {\n\t\tshort: \"A\",\n\t\ttakesValue: false\n\t},\n\tshowEnds: {\n\t\tshort: \"E\",\n\t\ttakesValue: false\n\t},\n\tshowNonprinting: {\n\t\tshort: \"v\",\n\t\ttakesValue: false\n\t},\n\tshowTabs: {\n\t\tshort: \"T\",\n\t\ttakesValue: false\n\t},\n\tsqueezeBlank: {\n\t\tshort: \"s\",\n\t\ttakesValue: false\n\t}\n});\n/**\n* Compile a cat command from SimpleCommandIR to StepIR.\n*/\nfunction compileCat(cmd) {\n\tconst parsed = parseCatArgs(cmd.args.map(expandedWordToString));\n\tconst fileArgs = [];\n\tfor (const positionalIndex of parsed.positionalIndices) {\n\t\tconst arg = cmd.args[positionalIndex];\n\t\tif (arg !== void 0) fileArgs.push(arg);\n\t}\n\tconst hasInputRedirection = cmd.redirections.some((redirection) => redirection.kind === \"input\");\n\tif (fileArgs.length === 0 && !hasInputRedirection) throw new Error(\"cat requires at least one file\");\n\treturn {\n\t\tcmd: \"cat\",\n\t\targs: {\n\t\t\tfiles: fileArgs,\n\t\t\tnumberLines: parsed.flags.number === true,\n\t\t\tnumberNonBlank: parsed.flags.numberNonBlank === true,\n\t\t\tshowAll: parsed.flags.showAll === true,\n\t\t\tshowEnds: parsed.flags.showEnds === true,\n\t\t\tshowNonprinting: parsed.flags.showNonprinting === true,\n\t\t\tshowTabs: parsed.flags.showTabs === true,\n\t\t\tsqueezeBlank: parsed.flags.squeezeBlank === true\n\t\t}\n\t};\n}\n\n//#endregion\n//#region src/compile/command/cd/cd.ts\n/**\n* cd command handler for the AST-based compiler.\n*/\nconst ROOT_DIRECTORY = \"/\";\n/**\n* Compile a cd command from SimpleCommandIR to StepIR.\n*/\nfunction compileCd(cmd) {\n\tconst positionalArgs = cmd.args[0]?.kind === \"literal\" && cmd.args[0].value === \"--\" ? cmd.args.slice(1) : cmd.args;\n\tif (positionalArgs.length > 1) throw new Error(\"cd accepts at most one path\");\n\treturn {\n\t\tcmd: \"cd\",\n\t\targs: { path: positionalArgs[0] ?? literal(ROOT_DIRECTORY) }\n\t};\n}\n\n//#endregion\n//#region src/compile/command/cp/cp.ts\n/**\n* cp command handler for the AST-based compiler.\n*/\nconst parseCpArgs = createWordParser({\n\tforce: {\n\t\tshort: \"f\",\n\t\ttakesValue: false\n\t},\n\tinteractive: {\n\t\tshort: \"i\",\n\t\ttakesValue: false\n\t},\n\trecursive: {\n\t\tshort: \"r\",\n\t\ttakesValue: false\n\t}\n}, expandedWordToString);\n/**\n* Compile a cp command from SimpleCommandIR to StepIR.\n*/\nfunction compileCp(cmd) {\n\tconst parsed = parseCpArgs(cmd.args, { unknownFlagPolicy: \"positional\" });\n\tconst recursive = parsed.flags.recursive === true;\n\tconst force = parsed.flags.force === true;\n\tconst interactive = parsed.flags.interactive === true;\n\tconst filteredArgs = parsed.positionalWords;\n\tif (filteredArgs.length < 2) throw new Error(\"cp requires source and destination\");\n\tconst dest = filteredArgs.pop();\n\tif (!dest) throw new Error(\"cp requires source and destination\");\n\treturn {\n\t\tcmd: \"cp\",\n\t\targs: {\n\t\t\tdest,\n\t\t\tforce,\n\t\t\tinteractive,\n\t\t\trecursive,\n\t\t\tsrcs: filteredArgs\n\t\t}\n\t};\n}\n\n//#endregion\n//#region src/compile/command/echo/echo.ts\nfunction compileEcho(cmd) {\n\treturn {\n\t\tcmd: \"echo\",\n\t\targs: { values: [...cmd.args] }\n\t};\n}\n\n//#endregion\n//#region src/compile/command/find/find.ts\nconst DEFAULT_ACTION = {\n\texplicit: false,\n\tkind: \"print\"\n};\nconst DEFAULT_TRAVERSAL = {\n\tdepth: false,\n\tmaxdepth: null,\n\tmindepth: 0\n};\nconst NON_NEGATIVE_INTEGER_REGEX = /^\\d+$/;\nfunction compileFind(command) {\n\treturn {\n\t\tcmd: \"find\",\n\t\targs: parseFindArgs(command.args)\n\t};\n}\nfunction parseFindArgs(argv) {\n\tconst state = {\n\t\taction: { ...DEFAULT_ACTION },\n\t\tdiagnostics: [],\n\t\tpredicates: [],\n\t\ttraversal: { ...DEFAULT_TRAVERSAL }\n\t};\n\tconst predicateStartIndex = findPredicateStartIndex(argv);\n\tconst explicitStartPaths = argv.slice(0, predicateStartIndex);\n\tconst startPaths = explicitStartPaths.length > 0 ? explicitStartPaths : [literal(\".\")];\n\tlet index = predicateStartIndex;\n\twhile (index < argv.length) {\n\t\tconst word = argv[index];\n\t\tif (!word) break;\n\t\tindex = parseFindToken(argv, index, expandedWordToString(word), state);\n\t}\n\treturn {\n\t\taction: state.action,\n\t\tdiagnostics: state.diagnostics,\n\t\tpredicates: state.predicates,\n\t\tstartPaths,\n\t\ttraversal: state.traversal,\n\t\tusageError: state.diagnostics.length > 0\n\t};\n}\nfunction createDiagnostic(code, token, tokenIndex, message) {\n\treturn {\n\t\tcode,\n\t\tmessage,\n\t\ttoken,\n\t\ttokenIndex\n\t};\n}\nfunction createMissingValueDiagnostic(token, tokenIndex) {\n\treturn createDiagnostic(\"missing-value\", token, tokenIndex, `find: missing argument to ${token}`);\n}\nfunction findPredicateStartIndex(argv) {\n\tfor (const [index, word] of argv.entries()) if (expandedWordToString(word).startsWith(\"-\")) return index;\n\treturn argv.length;\n}\nfunction parseFindToken(argv, index, token, state) {\n\tif (token === \"-name\" || token === \"-path\") return parseStringPredicate(argv, index, token, state);\n\tif (token === \"-type\") return parseTypePredicate(argv, index, state);\n\tif (token === \"-maxdepth\" || token === \"-mindepth\") return parseTraversalOption(argv, index, token, state);\n\tif (token === \"-depth\") {\n\t\tstate.traversal.depth = true;\n\t\treturn index + 1;\n\t}\n\tif (token === \"-print\") {\n\t\tstate.action.explicit = true;\n\t\treturn index + 1;\n\t}\n\tif (token.startsWith(\"-\")) {\n\t\tstate.diagnostics.push(createDiagnostic(\"unknown-predicate\", token, index, `find: unknown predicate: ${token}`));\n\t\treturn index + 1;\n\t}\n\tstate.diagnostics.push(createDiagnostic(\"unexpected-operand\", token, index, `find: unexpected argument: ${token}`));\n\treturn index + 1;\n}\nfunction parseStringPredicate(argv, index, token, state) {\n\tconst valueWord = argv[index + 1];\n\tif (!valueWord) {\n\t\tstate.diagnostics.push(createMissingValueDiagnostic(token, index));\n\t\treturn index + 1;\n\t}\n\tstate.predicates.push({\n\t\tkind: token === \"-name\" ? \"name\" : \"path\",\n\t\tpattern: valueWord\n\t});\n\treturn index + 2;\n}\nfunction parseTypePredicate(argv, index, state) {\n\tconst valueWord = argv[index + 1];\n\tif (!valueWord) {\n\t\tstate.diagnostics.push(createMissingValueDiagnostic(\"-type\", index));\n\t\treturn index + 1;\n\t}\n\tconst parsedType = parseFindTypeValue(valueWord, index + 1);\n\tif (\"diagnostic\" in parsedType) state.diagnostics.push(parsedType.diagnostic);\n\telse state.predicates.push({\n\t\tkind: \"type\",\n\t\ttypes: parsedType.types\n\t});\n\treturn index + 2;\n}\nfunction parseTraversalOption(argv, index, token, state) {\n\tconst valueWord = argv[index + 1];\n\tif (!valueWord) {\n\t\tstate.diagnostics.push(createMissingValueDiagnostic(token, index));\n\t\treturn index + 1;\n\t}\n\tconst parsedNumericValue = parseNonNegativeInteger(token, valueWord, index + 1);\n\tif (\"diagnostic\" in parsedNumericValue) {\n\t\tstate.diagnostics.push(parsedNumericValue.diagnostic);\n\t\treturn index + 2;\n\t}\n\tif (token === \"-maxdepth\") state.traversal.maxdepth = parsedNumericValue.value;\n\telse state.traversal.mindepth = parsedNumericValue.value;\n\treturn index + 2;\n}\nfunction parseFindTypeValue(word, tokenIndex) {\n\tconst rawValue = expandedWordToString(word);\n\tif (rawValue === \"\") return { diagnostic: createDiagnostic(\"invalid-value\", rawValue, tokenIndex, \"find: Arguments to -type should contain at least one letter\") };\n\tif (rawValue.endsWith(\",\")) return { diagnostic: createDiagnostic(\"invalid-value\", rawValue, tokenIndex, \"find: Last file type in list argument to -type is missing\") };\n\tconst parts = rawValue.split(\",\");\n\tif (parts.some((part) => part === \"\")) return { diagnostic: createDiagnostic(\"invalid-value\", rawValue, tokenIndex, \"find: File type in list argument to -type is missing\") };\n\tconst seen = /* @__PURE__ */ new Set();\n\tconst types = [];\n\tfor (const part of parts) {\n\t\tif (part.length > 1) return { diagnostic: createDiagnostic(\"invalid-value\", rawValue, tokenIndex, \"find: Must separate multiple arguments to -type with commas\") };\n\t\tif (part !== \"d\" && part !== \"f\") return { diagnostic: createDiagnostic(\"invalid-value\", rawValue, tokenIndex, `find: Unknown argument to -type: ${part}`) };\n\t\tif (seen.has(part)) return { diagnostic: createDiagnostic(\"invalid-value\", rawValue, tokenIndex, `find: Duplicate file type in list argument to -type: ${part}`) };\n\t\tseen.add(part);\n\t\ttypes.push(part);\n\t}\n\treturn { types };\n}\nfunction parseNonNegativeInteger(token, word, tokenIndex) {\n\tconst rawValue = expandedWordToString(word);\n\tif (!NON_NEGATIVE_INTEGER_REGEX.test(rawValue)) return { diagnostic: createDiagnostic(\"invalid-value\", rawValue, tokenIndex, `find: ${token}: non-numeric argument: ${rawValue}`) };\n\treturn { value: Number.parseInt(rawValue, 10) };\n}\n\n//#endregion\n//#region src/compile/command/grep/grep.ts\nconst CONTEXT_SHORTHAND_REGEX = /^-[0-9]+$/;\nconst UNKNOWN_FLAG_PREFIX$2 = \"Unknown flag:\";\nconst DEFAULT_OPTIONS = {\n\tafterContext: 0,\n\tbeforeContext: 0,\n\tbinaryWithoutMatch: false,\n\tbyteOffset: false,\n\tcountOnly: false,\n\tdirectories: \"read\",\n\texcludeDir: [],\n\texcludeFiles: [],\n\tfilenameMode: \"default\",\n\thelp: false,\n\tignoreCase: false,\n\tincludeFiles: [],\n\tinvertMatch: false,\n\tlineNumber: false,\n\tlineRegexp: false,\n\tlistFilesWithMatches: false,\n\tlistFilesWithoutMatch: false,\n\tmaxCount: null,\n\tmode: \"bre\",\n\tnoMessages: false,\n\tnullData: false,\n\tonlyMatching: false,\n\tquiet: false,\n\trecursive: false,\n\ttextMode: false,\n\tversion: false,\n\twordRegexp: false\n};\nconst parseGrepWords = createWordParser({\n\tafterContext: grepValueFlag({\n\t\tlong: \"after-context\",\n\t\tshort: \"A\"\n\t}),\n\tbeforeContext: grepValueFlag({\n\t\tlong: \"before-context\",\n\t\tshort: \"B\"\n\t}),\n\tbinaryFile: grepValueFlag({ long: \"binary-file\" }),\n\tbyteOffset: grepBooleanFlag({\n\t\tlong: \"byte-offset\",\n\t\tshort: \"b\"\n\t}),\n\tcontext: grepValueFlag({\n\t\tlong: \"context\",\n\t\tshort: \"C\"\n\t}),\n\tcountOnly: grepBooleanFlag({\n\t\tlong: \"count\",\n\t\tshort: \"c\"\n\t}),\n\tdereferenceRecursive: grepBooleanFlag({\n\t\tlong: \"dereference-recursive\",\n\t\tshort: \"R\"\n\t}),\n\tdirectories: grepValueFlag({ long: \"directories\" }),\n\tdevices: grepValueFlag({\n\t\tlong: \"devices\",\n\t\tshort: \"D\"\n\t}),\n\texclude: grepValueFlag({ long: \"exclude\" }),\n\texcludeDir: grepValueFlag({ long: \"exclude-dir\" }),\n\tfile: grepValueFlag({\n\t\tlong: \"file\",\n\t\tshort: \"f\"\n\t}),\n\tfilesWithMatches: grepBooleanFlag({\n\t\tlong: \"files-with-matches\",\n\t\tshort: \"l\"\n\t}),\n\tfilesWithoutMatch: grepBooleanFlag({\n\t\tlong: \"files-without-match\",\n\t\tshort: \"L\"\n\t}),\n\thelp: grepBooleanFlag({ long: \"help\" }),\n\tignoreCase: grepBooleanFlag({\n\t\tlong: \"ignore-case\",\n\t\tshort: \"i\"\n\t}),\n\tinclude: grepValueFlag({ long: \"include\" }),\n\tinvertMatch: grepBooleanFlag({\n\t\tlong: \"invert-match\",\n\t\tshort: \"v\"\n\t}),\n\tlineNumber: grepBooleanFlag({\n\t\tlong: \"line-number\",\n\t\tshort: \"n\"\n\t}),\n\tlineRegexp: grepBooleanFlag({\n\t\tlong: \"line-regexp\",\n\t\tshort: \"x\"\n\t}),\n\tmaxCount: grepValueFlag({\n\t\tlong: \"max-count\",\n\t\tshort: \"m\"\n\t}),\n\tmodeBasic: grepBooleanFlag({\n\t\tlong: \"basic-regexp\",\n\t\tshort: \"G\"\n\t}),\n\tmodeExtended: grepBooleanFlag({\n\t\tlong: \"extended-regexp\",\n\t\tshort: \"E\"\n\t}),\n\tmodeFixed: grepBooleanFlag({\n\t\tlong: \"fixed-strings\",\n\t\tshort: \"F\"\n\t}),\n\tmodePerl: grepBooleanFlag({\n\t\tlong: \"perl-regexp\",\n\t\tshort: \"P\"\n\t}),\n\tnoFilename: grepBooleanFlag({\n\t\tlong: \"no-filename\",\n\t\tshort: \"h\"\n\t}),\n\tnoMessages: grepBooleanFlag({\n\t\tlong: \"no-messages\",\n\t\tshort: \"s\"\n\t}),\n\tnullData: grepBooleanFlag({\n\t\tlong: \"null-data\",\n\t\tshort: \"z\"\n\t}),\n\tonlyMatching: grepBooleanFlag({\n\t\tlong: \"only-matching\",\n\t\tshort: \"o\"\n\t}),\n\tpattern: grepValueFlag({\n\t\tlong: \"regexp\",\n\t\tshort: \"e\"\n\t}),\n\tquiet: grepBooleanFlag({\n\t\tlong: \"quiet\",\n\t\tshort: \"q\"\n\t}),\n\trecursive: grepBooleanFlag({\n\t\tlong: \"recursive\",\n\t\tshort: \"r\"\n\t}),\n\tsilent: grepBooleanFlag({ long: \"silent\" }),\n\ttextMode: grepBooleanFlag({\n\t\tlong: \"text\",\n\t\tshort: \"a\"\n\t}),\n\tversion: grepBooleanFlag({ long: \"version\" }),\n\twithFilename: grepBooleanFlag({\n\t\tlong: \"with-filename\",\n\t\tshort: \"H\"\n\t}),\n\twordRegexp: grepBooleanFlag({\n\t\tlong: \"word-regexp\",\n\t\tshort: \"w\"\n\t})\n}, expandedWordToString);\n/**\n* Compile a grep command from SimpleCommandIR to StepIR.\n*/\nfunction compileGrep(cmd) {\n\treturn {\n\t\tcmd: \"grep\",\n\t\targs: parseGrepArgs(cmd.args)\n\t};\n}\nfunction parseGrepArgs(argv) {\n\tconst parsed = parseGrepWords(argv, {\n\t\terrorPolicy: \"diagnostic\",\n\t\tunknownFlagPolicy: \"diagnostic\"\n\t});\n\tconst options = createDefaultOptions();\n\tconst diagnostics = parsed.diagnostics.map(mapParseDiagnostic);\n\tapplyBooleanOptions(parsed, options);\n\tapplyModeOption(parsed, options);\n\tapplyFilenameMode(parsed, options);\n\tapplyFileListingMode(parsed, options);\n\tapplyBinaryFileOption(parsed, argv, options);\n\tapplyDirectoriesOption(parsed, argv, options);\n\tapplyMaxCountOption(parsed, argv, options, diagnostics);\n\tapplyContextOptions(parsed, argv, options, diagnostics);\n\toptions.excludeFiles = collectStringValues(parsed, argv, \"exclude\");\n\toptions.excludeDir = collectStringValues(parsed, argv, \"excludeDir\");\n\toptions.includeFiles = collectStringValues(parsed, argv, \"include\");\n\tconst explicitPatterns = collectExpandedValues(parsed, argv, \"pattern\");\n\tconst patternFiles = collectExpandedValues(parsed, argv, \"file\");\n\treturn {\n\t\tdiagnostics,\n\t\texplicitPatterns,\n\t\tfileOperands: assignImplicitPattern(explicitPatterns, patternFiles, collectPositionalOperands(parsed, argv, diagnostics)),\n\t\tnoPatternsYet: explicitPatterns.length === 0 && patternFiles.length === 0,\n\t\toptions,\n\t\tpatternFiles,\n\t\tusageError: diagnostics.length > 0\n\t};\n}\nfunction grepBooleanFlag(options) {\n\treturn {\n\t\tlong: options.long,\n\t\tshort: options.short,\n\t\ttakesValue: false\n\t};\n}\nfunction grepValueFlag(options) {\n\treturn {\n\t\tallowFlagLikeValue: true,\n\t\tambiguousShortValuePolicy: \"value\",\n\t\tlong: options.long,\n\t\tmultiple: true,\n\t\tshort: options.short,\n\t\ttakesValue: true\n\t};\n}\nfunction createDefaultOptions() {\n\treturn {\n\t\t...DEFAULT_OPTIONS,\n\t\texcludeDir: [],\n\t\texcludeFiles: [],\n\t\tincludeFiles: []\n\t};\n}\nfunction applyBooleanOptions(parsed, options) {\n\toptions.byteOffset = hasFlag(parsed, \"byteOffset\");\n\toptions.countOnly = hasFlag(parsed, \"countOnly\");\n\toptions.help = hasFlag(parsed, \"help\");\n\toptions.ignoreCase = hasFlag(parsed, \"ignoreCase\");\n\toptions.invertMatch = hasFlag(parsed, \"invertMatch\");\n\toptions.lineNumber = hasFlag(parsed, \"lineNumber\");\n\toptions.lineRegexp = hasFlag(parsed, \"lineRegexp\");\n\toptions.noMessages = hasFlag(parsed, \"noMessages\");\n\toptions.nullData = hasFlag(parsed, \"nullData\");\n\toptions.onlyMatching = hasFlag(parsed, \"onlyMatching\");\n\toptions.quiet = hasFlag(parsed, \"quiet\") || hasFlag(parsed, \"silent\");\n\toptions.recursive = hasFlag(parsed, \"recursive\") || hasFlag(parsed, \"dereferenceRecursive\");\n\toptions.textMode = hasFlag(parsed, \"textMode\");\n\toptions.version = hasFlag(parsed, \"version\");\n\toptions.wordRegexp = hasFlag(parsed, \"wordRegexp\");\n}\nfunction applyModeOption(parsed, options) {\n\tconst mode = pickLatestByOrder(parsed, [\n\t\t{\n\t\t\tcanonical: \"modeBasic\",\n\t\t\tvalue: \"bre\"\n\t\t},\n\t\t{\n\t\t\tcanonical: \"modeExtended\",\n\t\t\tvalue: \"ere\"\n\t\t},\n\t\t{\n\t\t\tcanonical: \"modeFixed\",\n\t\t\tvalue: \"fixed\"\n\t\t},\n\t\t{\n\t\t\tcanonical: \"modePerl\",\n\t\t\tvalue: \"pcre\"\n\t\t}\n\t]);\n\tif (mode !== void 0) options.mode = mode;\n}\nfunction applyFilenameMode(parsed, options) {\n\tconst mode = pickLatestByOrder(parsed, [{\n\t\tcanonical: \"withFilename\",\n\t\tvalue: \"always\"\n\t}, {\n\t\tcanonical: \"noFilename\",\n\t\tvalue: \"never\"\n\t}]);\n\tif (mode !== void 0) options.filenameMode = mode;\n}\nfunction applyFileListingMode(parsed, options) {\n\tconst mode = pickLatestByOrder(parsed, [{\n\t\tcanonical: \"filesWithMatches\",\n\t\tvalue: \"with\"\n\t}, {\n\t\tcanonical: \"filesWithoutMatch\",\n\t\tvalue: \"without\"\n\t}]);\n\tif (mode === \"with\") {\n\t\toptions.listFilesWithMatches = true;\n\t\toptions.listFilesWithoutMatch = false;\n\t}\n\tif (mode === \"without\") {\n\t\toptions.listFilesWithoutMatch = true;\n\t\toptions.listFilesWithMatches = false;\n\t}\n}\nfunction applyBinaryFileOption(parsed, argv, options) {\n\tfor (const occurrence of getValueOccurrences(parsed, argv, \"binaryFile\")) options.binaryWithoutMatch = occurrence.value === \"without-match\";\n}\nfunction applyDirectoriesOption(parsed, argv, options) {\n\tfor (const occurrence of getValueOccurrences(parsed, argv, \"directories\")) options.directories = occurrence.value === \"skip\" ? \"skip\" : \"read\";\n}\nfunction applyMaxCountOption(parsed, argv, options, diagnostics) {\n\tfor (const occurrence of getValueOccurrences(parsed, argv, \"maxCount\")) {\n\t\tconst parsedValue = parseNumericOption(occurrence.value);\n\t\tif (parsedValue === null) {\n\t\t\tdiagnostics.push(makeDiagnostic(\"invalid-value\", occurrence.token, occurrence.tokenIndex, makeInvalidNumericValueMessage(\"maxCount\", occurrence.token)));\n\t\t\tcontinue;\n\t\t}\n\t\toptions.maxCount = parsedValue;\n\t}\n}\nfunction applyContextOptions(parsed, argv, options, diagnostics) {\n\tconst assignments = [];\n\tassignments.push(...collectFlagContextAssignments(parsed, argv, diagnostics));\n\tconst endOfOptionsIndex = findEndOfOptionsIndex(argv);\n\tfor (const positionalIndex of parsed.positionalIndices) {\n\t\tconst word = argv[positionalIndex];\n\t\tif (!word || positionalIndex >= endOfOptionsIndex) continue;\n\t\tconst token = expandedWordToString(word);\n\t\tif (!CONTEXT_SHORTHAND_REGEX.test(token)) continue;\n\t\tconst parsedValue = parseNumericOption(token.slice(1));\n\t\tif (parsedValue === null) {\n\t\t\tdiagnostics.push(makeDiagnostic(\"invalid-value\", token, positionalIndex, `Invalid numeric option value in \"${token}\".`));\n\t\t\tcontinue;\n\t\t}\n\t\tassignments.push({\n\t\t\tkind: \"both\",\n\t\t\ttokenIndex: positionalIndex,\n\t\t\tvalue: parsedValue\n\t\t});\n\t}\n\tassignments.sort((a, b) => a.tokenIndex - b.tokenIndex);\n\tfor (const assignment of assignments) {\n\t\tif (assignment.kind === \"after\") {\n\t\t\toptions.afterContext = assignment.value;\n\t\t\tcontinue;\n\t\t}\n\t\tif (assignment.kind === \"before\") {\n\t\t\toptions.beforeContext = assignment.value;\n\t\t\tcontinue;\n\t\t}\n\t\toptions.beforeContext = assignment.value;\n\t\toptions.afterContext = assignment.value;\n\t}\n}\nfunction collectFlagContextAssignments(parsed, argv, diagnostics) {\n\tconst assignments = [];\n\tfor (const [canonical, kind] of [\n\t\t[\"afterContext\", \"after\"],\n\t\t[\"beforeContext\", \"before\"],\n\t\t[\"context\", \"both\"]\n\t]) for (const occurrence of getValueOccurrences(parsed, argv, canonical)) {\n\t\tconst parsedValue = parseNumericOption(occurrence.value);\n\t\tif (parsedValue === null) {\n\t\t\tdiagnostics.push(makeDiagnostic(\"invalid-value\", occurrence.token, occurrence.tokenIndex, makeInvalidNumericValueMessage(canonical, occurrence.token)));\n\t\t\tcontinue;\n\t\t}\n\t\tassignments.push({\n\t\t\tkind,\n\t\t\ttokenIndex: occurrence.tokenIndex,\n\t\t\tvalue: parsedValue\n\t\t});\n\t}\n\treturn assignments;\n}\nfunction collectPositionalOperands(parsed, argv, diagnostics) {\n\tconst endOfOptionsIndex = findEndOfOptionsIndex(argv);\n\tconst positionalOperands = [];\n\tfor (const positionalIndex of parsed.positionalIndices) {\n\t\tconst word = argv[positionalIndex];\n\t\tif (!word) continue;\n\t\tif (positionalIndex < endOfOptionsIndex) {\n\t\t\tconst token = expandedWordToString(word);\n\t\t\tif (CONTEXT_SHORTHAND_REGEX.test(token)) continue;\n\t\t\tif (token.startsWith(\"-\") && token !== \"-\") {\n\t\t\t\tif (isKnownDiagnosticToken(diagnostics, token, positionalIndex)) continue;\n\t\t\t\tdiagnostics.push(makeDiagnostic(\"unknown-option\", token, positionalIndex, `Unknown grep option: ${token}`));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tpositionalOperands.push(word);\n\t}\n\treturn positionalOperands;\n}\nfunction assignImplicitPattern(explicitPatterns, patternFiles, positionalOperands) {\n\tconst fileOperands = [];\n\tlet implicitPatternAssigned = false;\n\tfor (const operand of positionalOperands) {\n\t\tif (!implicitPatternAssigned && explicitPatterns.length === 0 && patternFiles.length === 0) {\n\t\t\texplicitPatterns.push(operand);\n\t\t\timplicitPatternAssigned = true;\n\t\t\tcontinue;\n\t\t}\n\t\tfileOperands.push(operand);\n\t}\n\treturn fileOperands;\n}\nfunction collectStringValues(parsed, argv, canonical) {\n\treturn getValueOccurrences(parsed, argv, canonical).map((occurrence) => occurrence.value);\n}\nfunction collectExpandedValues(parsed, argv, canonical) {\n\tconst values = [];\n\tfor (const occurrence of getValueOccurrences(parsed, argv, canonical)) {\n\t\tif (occurrence.source === \"arg\") {\n\t\t\tconst word = argv[occurrence.valueIndex];\n\t\t\tvalues.push(word ?? literal(occurrence.value));\n\t\t\tcontinue;\n\t\t}\n\t\tvalues.push(literal(occurrence.value));\n\t}\n\treturn values;\n}\nfunction getValueOccurrences(parsed, argv, canonical) {\n\tconst values = normalizeValueList(parsed.flags[canonical]);\n\tconst valueIndices = parsed.consumedValueIndices[canonical] ?? [];\n\tconst valueSources = parsed.consumedValueSources[canonical] ?? [];\n\tconst orders = parsed.flagOccurrenceOrder[canonical] ?? [];\n\tconst count = Math.min(values.length, valueIndices.length, valueSources.length, orders.length);\n\tconst occurrences = [];\n\tfor (let index = 0; index < count; index += 1) {\n\t\tconst value = values[index];\n\t\tconst valueIndex = valueIndices[index];\n\t\tconst source = valueSources[index];\n\t\tconst order = orders[index];\n\t\tif (value === void 0 || valueIndex === void 0 || source === void 0 || order === void 0) continue;\n\t\tconst tokenIndex = source === \"arg\" ? valueIndex - 1 : valueIndex;\n\t\tconst tokenWord = argv[tokenIndex];\n\t\tlet token = canonical;\n\t\tif (tokenWord !== void 0) token = expandedWordToString(tokenWord);\n\t\telse if (source === \"inline\") token = value;\n\t\toccurrences.push({\n\t\t\torder,\n\t\t\tsource,\n\t\t\ttoken,\n\t\t\ttokenIndex,\n\t\t\tvalue,\n\t\t\tvalueIndex\n\t\t});\n\t}\n\toccurrences.sort((a, b) => a.order - b.order);\n\treturn occurrences;\n}\nfunction normalizeValueList(value) {\n\tif (typeof value === \"string\") return [value];\n\tif (Array.isArray(value)) return value;\n\treturn [];\n}\nfunction hasFlag(parsed, canonical) {\n\tconst occurrences = parsed.flagOccurrenceOrder[canonical];\n\treturn occurrences !== void 0 && occurrences.length > 0;\n}\nfunction pickLatestByOrder(parsed, entries) {\n\tlet selected;\n\tlet selectedOrder = -1;\n\tfor (const entry of entries) {\n\t\tconst order = parsed.flagOccurrenceOrder[entry.canonical]?.at(-1);\n\t\tif (order === void 0 || order < selectedOrder) continue;\n\t\tselectedOrder = order;\n\t\tselected = entry.value;\n\t}\n\treturn selected;\n}\nfunction findEndOfOptionsIndex(argv) {\n\tfor (const [index, word] of argv.entries()) if (expandedWordToString(word) === \"--\") return index;\n\treturn Number.POSITIVE_INFINITY;\n}\nfunction mapParseDiagnostic(diagnostic) {\n\tif (diagnostic.code === \"unknown-flag\" || diagnostic.message.startsWith(UNKNOWN_FLAG_PREFIX$2)) return makeDiagnostic(\"unknown-option\", diagnostic.token, diagnostic.tokenIndex, `Unknown grep option: ${diagnostic.token}`);\n\tif (diagnostic.message.includes(\"requires a value\")) return makeDiagnostic(\"missing-value\", diagnostic.token, diagnostic.tokenIndex, `Option ${diagnostic.token} requires a value.`);\n\treturn makeDiagnostic(\"unknown-option\", diagnostic.token, diagnostic.tokenIndex, diagnostic.message);\n}\nfunction isKnownDiagnosticToken(diagnostics, token, tokenIndex) {\n\treturn diagnostics.some((diagnostic) => diagnostic.token === token && diagnostic.tokenIndex === tokenIndex);\n}\nfunction parseNumericOption(value) {\n\tif (value === null || value === \"\") return null;\n\tconst parsed = Number.parseInt(value, 10);\n\tif (!Number.isFinite(parsed) || parsed < 0) return null;\n\treturn parsed;\n}\nfunction makeInvalidNumericValueMessage(canonical, token) {\n\tif (token.startsWith(\"--\")) return `Invalid numeric value for option ${splitLongOption(token)}.`;\n\tswitch (canonical) {\n\t\tcase \"afterContext\": return \"Invalid value for -A. Expected a non-negative integer.\";\n\t\tcase \"beforeContext\": return \"Invalid value for -B. Expected a non-negative integer.\";\n\t\tcase \"context\": return \"Invalid value for -C. Expected a non-negative integer.\";\n\t\tcase \"maxCount\": return \"Invalid value for -m. Expected a non-negative integer.\";\n\t\tdefault: return \"Invalid numeric value.\";\n\t}\n}\nfunction splitLongOption(token) {\n\tconst equalsIndex = token.indexOf(\"=\");\n\tif (equalsIndex === -1) return token;\n\treturn token.slice(0, equalsIndex);\n}\nfunction makeDiagnostic(code, token, tokenIndex, message) {\n\treturn {\n\t\tcode,\n\t\tmessage,\n\t\ttoken,\n\t\ttokenIndex\n\t};\n}\n\n//#endregion\n//#region src/compile/command/head/head.ts\n/**\n* head command handler for the AST-based compiler.\n*/\nconst DEFAULT_LINE_COUNT$1 = 10;\nconst parseHeadArgs = createWordParser({ lines: {\n\tmultiple: true,\n\tshort: \"n\",\n\ttakesValue: true\n} }, expandedWordToString);\nconst MISSING_N_VALUE_PREFIX$1 = \"Flag -n requires a value\";\nconst UNKNOWN_FLAG_PREFIX$1 = \"Unknown flag:\";\n/**\n* Compile a head command from SimpleCommandIR to StepIR.\n*/\nfunction compileHead(cmd) {\n\tconst parsed = parseHeadArgsOrThrow(cmd.args);\n\tconst n = parseHeadCount(parsed.flags.lines);\n\treturn {\n\t\tcmd: \"head\",\n\t\targs: {\n\t\t\tfiles: parsed.positionalWords,\n\t\t\tn\n\t\t}\n\t};\n}\nfunction parseHeadCount(value) {\n\tconst lastValue = getLastValueToken$1(value);\n\tif (lastValue === void 0) return DEFAULT_LINE_COUNT$1;\n\tconst parsedValue = Number(lastValue);\n\tif (!Number.isFinite(parsedValue)) throw new Error(\"Invalid head count\");\n\treturn parsedValue;\n}\nfunction getLastValueToken$1(value) {\n\tif (value === void 0) return;\n\tif (typeof value === \"string\") return value;\n\tif (Array.isArray(value)) return value.at(-1);\n\tthrow new Error(\"Invalid head count\");\n}\nfunction parseHeadArgsOrThrow(args) {\n\ttry {\n\t\treturn parseHeadArgs(args, {\n\t\t\tnegativeNumberFlag: \"lines\",\n\t\t\tnegativeNumberPolicy: \"value\"\n\t\t});\n\t} catch (error) {\n\t\tif (!(error instanceof Error)) throw new Error(\"Unknown head option\");\n\t\tif (error.message.startsWith(MISSING_N_VALUE_PREFIX$1)) throw new Error(\"head -n requires a number\");\n\t\tif (error.message.startsWith(UNKNOWN_FLAG_PREFIX$1)) throw new Error(\"Unknown head option\");\n\t\tthrow error;\n\t}\n}\n\n//#endregion\n//#region src/compile/command/ls/ls.ts\n/**\n* ls command handler for the AST-based compiler.\n*/\nconst parseLsArgs = createWordParser({\n\tlongFormat: {\n\t\tshort: \"l\",\n\t\ttakesValue: false\n\t},\n\tshowAll: {\n\t\tshort: \"a\",\n\t\ttakesValue: false\n\t}\n}, expandedWordToString);\n/**\n* Compile an ls command from SimpleCommandIR to StepIR.\n*/\nfunction compileLs(cmd) {\n\tconst parsed = parseLsArgs(cmd.args, { unknownFlagPolicy: \"positional\" });\n\tconst paths = parsed.positionalWords.length === 0 ? [literal(\".\")] : parsed.positionalWords;\n\treturn {\n\t\tcmd: \"ls\",\n\t\targs: {\n\t\t\tlongFormat: parsed.flags.longFormat === true,\n\t\t\tpaths,\n\t\t\tshowAll: parsed.flags.showAll === true\n\t\t}\n\t};\n}\n\n//#endregion\n//#region src/compile/command/mkdir/mkdir.ts\n/**\n* mkdir command handler for the AST-based compiler.\n*/\nconst parseMkdirArgs = createWordParser({ parents: {\n\tshort: \"p\",\n\ttakesValue: false\n} }, expandedWordToString);\n/**\n* Compile a mkdir command from SimpleCommandIR to StepIR.\n*/\nfunction compileMkdir(cmd) {\n\tconst parsed = parseMkdirArgs(cmd.args, { unknownFlagPolicy: \"positional\" });\n\tconst parents = parsed.flags.parents === true;\n\tconst recursive = parents;\n\tconst paths = parsed.positionalWords;\n\tif (paths.length === 0) throw new Error(\"mkdir requires at least one path\");\n\treturn {\n\t\tcmd: \"mkdir\",\n\t\targs: {\n\t\t\tparents,\n\t\t\tpaths,\n\t\t\trecursive\n\t\t}\n\t};\n}\n\n//#endregion\n//#region src/compile/command/mv/mv.ts\n/**\n* mv command handler for the AST-based compiler.\n*/\nconst parseMvArgs = createWordParser({\n\tforce: {\n\t\tshort: \"f\",\n\t\ttakesValue: false\n\t},\n\tinteractive: {\n\t\tshort: \"i\",\n\t\ttakesValue: false\n\t}\n}, expandedWordToString);\n/**\n* Compile a mv command from SimpleCommandIR to StepIR.\n*/\nfunction compileMv(cmd) {\n\tconst parsed = parseMvArgs(cmd.args, { unknownFlagPolicy: \"positional\" });\n\tconst force = parsed.flags.force === true;\n\tconst interactive = parsed.flags.interactive === true;\n\tconst filteredArgs = parsed.positionalWords;\n\tif (filteredArgs.length < 2) throw new Error(\"mv requires source and destination\");\n\tconst dest = filteredArgs.pop();\n\tif (!dest) throw new Error(\"mv requires source and destination\");\n\treturn {\n\t\tcmd: \"mv\",\n\t\targs: {\n\t\t\tdest,\n\t\t\tforce,\n\t\t\tinteractive,\n\t\t\tsrcs: filteredArgs\n\t\t}\n\t};\n}\n\n//#endregion\n//#region src/compile/command/pwd/pwd.ts\n/**\n* Compile a pwd command from SimpleCommandIR to StepIR.\n*/\nfunction compilePwd(cmd) {\n\tif (cmd.args.length > 0) throw new Error(\"pwd does not take any arguments\");\n\treturn {\n\t\tcmd: \"pwd\",\n\t\targs: {}\n\t};\n}\n\n//#endregion\n//#region src/compile/command/read/read.ts\nfunction compileRead(cmd) {\n\tif (cmd.args.length !== 1) throw new Error(\"read requires exactly one variable name\");\n\tconst name = cmd.args[0];\n\tif (!name) throw new Error(\"read requires exactly one variable name\");\n\treturn {\n\t\tcmd: \"read\",\n\t\targs: { name }\n\t};\n}\n\n//#endregion\n//#region src/compile/command/rm/rm.ts\n/**\n* rm command handler for the AST-based compiler.\n*/\nconst parseRmArgs = createWordParser({\n\tforce: {\n\t\tshort: \"f\",\n\t\ttakesValue: false\n\t},\n\tinteractive: {\n\t\tshort: \"i\",\n\t\ttakesValue: false\n\t},\n\trecursive: {\n\t\tshort: \"r\",\n\t\ttakesValue: false\n\t}\n}, expandedWordToString);\n/**\n* Compile a rm command from SimpleCommandIR to StepIR.\n*/\nfunction compileRm(cmd) {\n\tconst parsed = parseRmArgs(cmd.args, { unknownFlagPolicy: \"positional\" });\n\tconst recursive = parsed.flags.recursive === true;\n\tconst force = parsed.flags.force === true;\n\tconst interactive = parsed.flags.interactive === true;\n\tconst paths = parsed.positionalWords;\n\tif (paths.length === 0) throw new Error(\"rm requires at least one path\");\n\treturn {\n\t\tcmd: \"rm\",\n\t\targs: {\n\t\t\tforce,\n\t\t\tinteractive,\n\t\t\tpaths,\n\t\t\trecursive\n\t\t}\n\t};\n}\n\n//#endregion\n//#region src/compile/command/set/set.ts\nconst parseSetArgs = createWordParser({\n\tglobal: {\n\t\tshort: \"g\",\n\t\ttakesValue: false\n\t},\n\tlocal: {\n\t\tshort: \"l\",\n\t\ttakesValue: false\n\t}\n}, expandedWordToString);\nfunction compileSet(cmd) {\n\tconst parsed = parseSetArgs(cmd.args, { unknownFlagPolicy: \"error\" });\n\tconst isGlobal = parsed.flags.global === true;\n\tif (isGlobal === (parsed.flags.local === true)) throw new Error(\"set requires exactly one scope flag: -g or -l\");\n\tconst [name, ...values] = parsed.positionalWords;\n\tif (!name) throw new Error(\"set requires a variable name\");\n\treturn {\n\t\tcmd: \"set\",\n\t\targs: {\n\t\t\tscope: isGlobal ? \"global\" : \"local\",\n\t\t\tname,\n\t\t\tvalues\n\t\t}\n\t};\n}\n\n//#endregion\n//#region src/compile/command/string/string.ts\nfunction compileString(cmd) {\n\tconst [subcommand, ...operands] = cmd.args;\n\tif (!subcommand) throw new Error(\"string requires a subcommand\");\n\treturn {\n\t\tcmd: \"string\",\n\t\targs: {\n\t\t\tsubcommand,\n\t\t\toperands\n\t\t}\n\t};\n}\n\n//#endregion\n//#region src/compile/command/tail/tail.ts\n/**\n* tail command handler for the AST-based compiler.\n*/\nconst DEFAULT_LINE_COUNT = 10;\nconst parseTailArgs = createWordParser({ lines: {\n\tmultiple: true,\n\tshort: \"n\",\n\ttakesValue: true\n} }, expandedWordToString);\nconst MISSING_N_VALUE_PREFIX = \"Flag -n requires a value\";\nconst UNKNOWN_FLAG_PREFIX = \"Unknown flag:\";\n/**\n* Compile a tail command from SimpleCommandIR to StepIR.\n*/\nfunction compileTail(cmd) {\n\tconst parsed = parseTailArgsOrThrow(cmd.args);\n\tconst n = parseTailCount(parsed.flags.lines);\n\treturn {\n\t\tcmd: \"tail\",\n\t\targs: {\n\t\t\tfiles: parsed.positionalWords,\n\t\t\tn\n\t\t}\n\t};\n}\nfunction parseTailCount(value) {\n\tconst lastValue = getLastValueToken(value);\n\tif (lastValue === void 0) return DEFAULT_LINE_COUNT;\n\tconst parsedValue = Number(lastValue);\n\tif (!Number.isFinite(parsedValue)) throw new Error(\"Invalid tail count\");\n\treturn parsedValue;\n}\nfunction getLastValueToken(value) {\n\tif (value === void 0) return;\n\tif (typeof value === \"string\") return value;\n\tif (Array.isArray(value)) return value.at(-1);\n\tthrow new Error(\"Invalid tail count\");\n}\nfunction parseTailArgsOrThrow(args) {\n\ttry {\n\t\treturn parseTailArgs(args, {\n\t\t\tnegativeNumberFlag: \"lines\",\n\t\t\tnegativeNumberPolicy: \"value\"\n\t\t});\n\t} catch (error) {\n\t\tthrow normalizeTailParseError(error);\n\t}\n}\nfunction normalizeTailParseError(error) {\n\tif (!(error instanceof Error)) return /* @__PURE__ */ new Error(\"Unknown tail option\");\n\tif (error.message.startsWith(MISSING_N_VALUE_PREFIX)) return /* @__PURE__ */ new Error(\"tail -n requires a number\");\n\tif (error.message.startsWith(UNKNOWN_FLAG_PREFIX)) return /* @__PURE__ */ new Error(\"Unknown tail option\");\n\treturn error;\n}\n\n//#endregion\n//#region src/compile/command/test/test.ts\nfunction compileTest(cmd) {\n\tif (cmd.args.length === 0) throw new Error(\"test requires operands\");\n\treturn {\n\t\tcmd: \"test\",\n\t\targs: { operands: [...cmd.args] }\n\t};\n}\n\n//#endregion\n//#region src/compile/command/touch/touch.ts\n/**\n* touch command handler for the AST-based compiler.\n*/\nconst parseTouchArgs = createWordParser({\n\taccessTimeOnly: {\n\t\tshort: \"a\",\n\t\ttakesValue: false\n\t},\n\tmodificationTimeOnly: {\n\t\tshort: \"m\",\n\t\ttakesValue: false\n\t}\n}, expandedWordToString);\n/**\n* Compile a touch command from SimpleCommandIR to StepIR.\n*/\nfunction compileTouch(cmd) {\n\tconst parsed = parseTouchArgs(cmd.args, { unknownFlagPolicy: \"positional\" });\n\tconst accessTimeOnly = parsed.flags.accessTimeOnly === true;\n\tconst modificationTimeOnly = parsed.flags.modificationTimeOnly === true;\n\tconst files = parsed.positionalWords.filter((arg) => {\n\t\treturn !expandedWordToString(arg).startsWith(\"-\");\n\t});\n\tif (files.length === 0) throw new Error(\"touch requires at least one file\");\n\treturn {\n\t\tcmd: \"touch\",\n\t\targs: {\n\t\t\taccessTimeOnly,\n\t\t\tfiles,\n\t\t\tmodificationTimeOnly\n\t\t}\n\t};\n}\n\n//#endregion\n//#region src/compile/command/handler.ts\nlet CommandHandler;\n(function(_CommandHandler) {\n\tconst handlers = {\n\t\tcat: compileCat,\n\t\tcd: compileCd,\n\t\tcp: compileCp,\n\t\techo: compileEcho,\n\t\tfind: compileFind,\n\t\tgrep: compileGrep,\n\t\thead: compileHead,\n\t\tls: compileLs,\n\t\tmkdir: compileMkdir,\n\t\tmv: compileMv,\n\t\tpwd: compilePwd,\n\t\tread: compileRead,\n\t\trm: compileRm,\n\t\tset: compileSet,\n\t\tstring: compileString,\n\t\ttail: compileTail,\n\t\ttest: compileTest,\n\t\ttouch: compileTouch\n\t};\n\tfunction get(name) {\n\t\tconst handler = handlers[name];\n\t\tif (!handler) throw new Error(`Unknown command: ${name}`);\n\t\treturn handler;\n\t}\n\t_CommandHandler.get = get;\n\tfunction has(name) {\n\t\treturn name in handlers;\n\t}\n\t_CommandHandler.has = has;\n\tfunction register(name, handler) {\n\t\thandlers[name] = handler;\n\t}\n\t_CommandHandler.register = register;\n})(CommandHandler || (CommandHandler = {}));\n\n//#endregion\n//#region src/compile/compile.ts\n/**\n* AST-based compiler for the Fish subset parser.\n*\n* This compiler traverses the AST and produces script-level IR\n* with enhanced word expansion information.\n*\n* Key differences from the old compile.ts:\n* - Accepts Program from the new parser (not ShellAST)\n* - Produces ScriptIR/PipelineIR with ExpandedWord types\n* - Preserves word structure for runtime expansion\n*/\n/**\n* Compile a Program AST to a ScriptIR.\n*\n* @param program The parsed Program AST\n* @returns The compiled ScriptIR\n*/\nfunction compile(program) {\n\treturn new ProgramCompiler().compileProgram(program);\n}\n/**\n* Compiler that traverses the AST to produce IR.\n*\n* Note: We don't implement the Visitor interface directly because\n* different AST nodes need to return different types. Instead, we\n* manually traverse the AST with type-specific methods.\n*/\nvar ProgramCompiler = class {\n\t/**\n\t* Compile a Program to a ScriptIR.\n\t*/\n\tcompileProgram(node) {\n\t\treturn { statements: node.statements.map((statement) => this.compileStatement(statement)) };\n\t}\n\t/**\n\t* Compile a script statement to ScriptStatementIR.\n\t*/\n\tcompileStatement(node) {\n\t\treturn {\n\t\t\tchainMode: node.chainMode,\n\t\t\tpipeline: this.compilePipeline(node.pipeline)\n\t\t};\n\t}\n\t/**\n\t* Compile a Pipeline to a PipelineIR.\n\t*/\n\tcompilePipeline(node) {\n\t\tconst commands = node.commands.map((cmd) => this.compileSimpleCommand(cmd));\n\t\tif (commands.length === 0) throw new Error(\"Pipeline must contain at least one command\");\n\t\tconst firstCmd = commands[0];\n\t\tif (!firstCmd) throw new Error(\"Pipeline must contain at least one command\");\n\t\treturn {\n\t\t\tsource: this.determineSource(firstCmd),\n\t\t\tsteps: commands.map((cmd) => this.compileCommandToStep(cmd)),\n\t\t\tfirstCommand: firstCmd\n\t\t};\n\t}\n\t/**\n\t* Compile a SimpleCommand to a SimpleCommandIR.\n\t*/\n\tcompileSimpleCommand(node) {\n\t\treturn {\n\t\t\tname: this.expandWord(node.name),\n\t\t\targs: node.args.map((arg) => this.expandWord(arg)),\n\t\t\tredirections: node.redirections.map((r) => this.compileRedirection(r))\n\t\t};\n\t}\n\t/**\n\t* Compile a Redirection to a RedirectionIR.\n\t*/\n\tcompileRedirection(node) {\n\t\treturn {\n\t\t\tkind: node.redirectKind,\n\t\t\ttarget: this.expandWord(node.target)\n\t\t};\n\t}\n\t/**\n\t* Expand a Word to an ExpandedWord.\n\t* Preserves ordered parts for mixed words instead of flattening them.\n\t*/\n\texpandWord(word) {\n\t\tif (word.parts.length === 0) return literal(\"\");\n\t\tconst expandedParts = word.parts.map((part) => this.expandWordPart(part));\n\t\tif (expandedParts.length === 1) {\n\t\t\tconst firstPart = expandedParts[0];\n\t\t\tif (!firstPart) return literal(\"\");\n\t\t\treturn firstPart;\n\t\t}\n\t\tif (expandedParts.every((part) => part.kind === \"literal\")) return literal(expandedParts.map((part) => {\n\t\t\tif (part.kind !== \"literal\") throw new Error(\"Expected literal word part\");\n\t\t\treturn part.value;\n\t\t}).join(\"\"));\n\t\treturn compound(expandedParts);\n\t}\n\t/**\n\t* Expand a single WordPart to an ExpandedWordPart.\n\t*/\n\texpandWordPart(part) {\n\t\tswitch (part.kind) {\n\t\t\tcase \"literal\": return literal(part.value);\n\t\t\tcase \"glob\": return glob(part.pattern);\n\t\t\tcase \"commandSub\": return commandSub(this.serializeProgram(part.program));\n\t\t\tdefault: {\n\t\t\t\tconst _exhaustive = part;\n\t\t\t\tthrow new Error(`Unknown word part kind: ${JSON.stringify(_exhaustive)}`);\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t* Determine the source for a pipeline based on the first command.\n\t*/\n\tdetermineSource(firstCmd) {\n\t\tconst firstArg = firstCmd.args[0];\n\t\tif (firstArg && !expandedWordHasCommandSub(firstArg)) return {\n\t\t\tkind: \"fs\",\n\t\t\tglob: expandedWordToString(firstArg)\n\t\t};\n\t\treturn {\n\t\t\tkind: \"fs\",\n\t\t\tglob: \"**/*\"\n\t\t};\n\t}\n\t/**\n\t* Compile a SimpleCommandIR to a StepIR.\n\t*/\n\tcompileCommandToStep(cmd) {\n\t\tconst cmdName = this.extractLiteralString(cmd.name);\n\t\tif (!cmdName) throw new Error(\"Command name must be a literal string\");\n\t\treturn {\n\t\t\t...CommandHandler.get(cmdName)(cmd),\n\t\t\tredirections: cmd.redirections\n\t\t};\n\t}\n\t/**\n\t* Extract the literal string value from an ExpandedWord.\n\t* Returns null if the word is not a literal.\n\t*/\n\textractLiteralString(word) {\n\t\tif (word.kind === \"literal\") return word.value;\n\t\treturn null;\n\t}\n\t/**\n\t* Serialize a Program AST back to a string representation.\n\t* Used for storing command substitution content.\n\t*/\n\tserializeProgram(program) {\n\t\treturn program.statements.map((statement) => this.serializePipeline(statement.pipeline)).join(\"; \");\n\t}\n\tserializePipeline(pipeline) {\n\t\treturn pipeline.commands.map((cmd) => {\n\t\t\tconst name = this.serializeWord(cmd.name);\n\t\t\tconst args = cmd.args.map((arg) => this.serializeWord(arg)).join(\" \");\n\t\t\treturn args ? `${name} ${args}` : name;\n\t\t}).join(\" | \");\n\t}\n\tserializeWord(word) {\n\t\treturn word.parts.map((part) => this.serializeWordPart(part)).join(\"\");\n\t}\n\tserializeWordPart(part) {\n\t\tswitch (part.kind) {\n\t\t\tcase \"literal\": return part.value;\n\t\t\tcase \"glob\": return part.pattern;\n\t\t\tcase \"commandSub\": return `(${this.serializeProgram(part.program)})`;\n\t\t\tdefault: {\n\t\t\t\tconst _exhaustive = part;\n\t\t\t\tthrow new Error(`Unknown word part kind: ${JSON.stringify(_exhaustive)}`);\n\t\t\t}\n\t\t}\n\t}\n};\n\n//#endregion\n//#region src/lexer/position.ts\n/**\n* Represents a position in source code.\n*/\nvar SourcePosition = class SourcePosition {\n\tline;\n\tcolumn;\n\toffset;\n\tconstructor(line, column, offset) {\n\t\tthis.line = line;\n\t\tthis.column = column;\n\t\tthis.offset = offset;\n\t}\n\tstatic ZERO = new SourcePosition(1, 1, 0);\n\ttoString() {\n\t\treturn `${this.line}:${this.column}`;\n\t}\n\tspan(end) {\n\t\treturn new SourceSpan(this, end);\n\t}\n};\n/**\n* Represents a span of source code from start to end position.\n*/\nvar SourceSpan = class {\n\tstart;\n\tend;\n\tconstructor(start, end) {\n\t\tthis.start = start;\n\t\tthis.end = end;\n\t}\n\ttoString() {\n\t\treturn `${this.start}-${this.end}`;\n\t}\n};\n\n//#endregion\n//#region src/lexer/context.ts\n/**\n* Lexer states for the fish subset lexer state machine.\n*\n* Simplified for the subset - only tracks quoting and command substitution.\n*/\nconst LexerState = {\n\tNORMAL: 0,\n\tSINGLE_QUOTED: 1,\n\tDOUBLE_QUOTED: 2,\n\tCOMMAND_SUB: 3\n};\n/**\n* Manages the lexer state stack for tracking nested contexts.\n*\n* Fish subset has simple quoting:\n* - Single quotes: literal, no escapes, no substitution\n* - Double quotes: command substitution allowed, minimal escaping (\\\", \\\\)\n*/\nvar StateContext = class {\n\tstack = [LexerState.NORMAL];\n\t/**\n\t* Get the current lexer state.\n\t*/\n\tget current() {\n\t\treturn this.stack.at(-1) ?? LexerState.NORMAL;\n\t}\n\t/**\n\t* Get the stack depth.\n\t*/\n\tget depth() {\n\t\treturn this.stack.length;\n\t}\n\t/**\n\t* Check if we're inside any quote context.\n\t*/\n\tget inQuotes() {\n\t\tconst s = this.current;\n\t\treturn s === LexerState.SINGLE_QUOTED || s === LexerState.DOUBLE_QUOTED;\n\t}\n\t/**\n\t* Check if we're inside single quotes.\n\t*/\n\tget inSingleQuote() {\n\t\treturn this.current === LexerState.SINGLE_QUOTED;\n\t}\n\t/**\n\t* Check if we're inside double quotes.\n\t*/\n\tget inDoubleQuote() {\n\t\treturn this.current === LexerState.DOUBLE_QUOTED;\n\t}\n\t/**\n\t* Check if we're inside a command substitution.\n\t*/\n\tget inCommandSub() {\n\t\treturn this.current === LexerState.COMMAND_SUB;\n\t}\n\t/**\n\t* Push a new state onto the stack.\n\t*/\n\tpush(state) {\n\t\tthis.stack.push(state);\n\t}\n\t/**\n\t* Pop the current state from the stack.\n\t*/\n\tpop() {\n\t\tif (this.stack.length > 1) return this.stack.pop() ?? LexerState.NORMAL;\n\t\treturn LexerState.NORMAL;\n\t}\n\t/**\n\t* Reset the context to initial state.\n\t*/\n\treset() {\n\t\tthis.stack = [LexerState.NORMAL];\n\t}\n\t/**\n\t* Check if any parent context is double-quoted.\n\t* Useful for determining if command substitution should occur.\n\t*/\n\thasDoubleQuoteParent() {\n\t\treturn this.stack.includes(LexerState.DOUBLE_QUOTED);\n\t}\n\t/**\n\t* Check if any parent context is single-quoted.\n\t* If true, no expansions should occur.\n\t*/\n\thasSingleQuoteParent() {\n\t\treturn this.stack.includes(LexerState.SINGLE_QUOTED);\n\t}\n};\n\n//#endregion\n//#region src/lexer/token.ts\n/**\n* Token types for the fish subset lexer.\n*\n* This is a simplified subset of fish shell syntax focused on:\n* - Pipelines\n* - Command substitution (...)\n* - Globbing (* ? [...])\n* - Basic quoting\n* - Comments\n*\n* NOT supported: variables, brace expansion, control flow, functions\n*/\nconst TokenKind = {\n\tEOF: 0,\n\tERROR: 1,\n\tNEWLINE: 2,\n\tCOMMENT: 3,\n\tWORD: 4,\n\tNAME: 5,\n\tNUMBER: 6,\n\tPIPE: 7,\n\tSEMICOLON: 8,\n\tLPAREN: 9,\n\tRPAREN: 10,\n\tLESS: 11,\n\tGREAT: 12\n};\n/**\n* Create an empty flags object.\n*/\nfunction createEmptyFlags() {\n\treturn {\n\t\tquoted: false,\n\t\tsingleQuoted: false,\n\t\tdoubleQuoted: false,\n\t\tcontainsExpansion: false,\n\t\tcontainsGlob: false\n\t};\n}\n/**\n* Check if any quote flag is set.\n*/\nfunction isQuoted(flags) {\n\treturn flags.quoted || flags.singleQuoted || flags.doubleQuoted;\n}\n/**\n* Human-readable names for token kinds.\n*/\nconst TOKEN_KIND_NAMES = {\n\t[TokenKind.EOF]: \"EOF\",\n\t[TokenKind.ERROR]: \"ERROR\",\n\t[TokenKind.NEWLINE]: \"NEWLINE\",\n\t[TokenKind.COMMENT]: \"COMMENT\",\n\t[TokenKind.WORD]: \"WORD\",\n\t[TokenKind.NAME]: \"NAME\",\n\t[TokenKind.NUMBER]: \"NUMBER\",\n\t[TokenKind.PIPE]: \"PIPE\",\n\t[TokenKind.SEMICOLON]: \"SEMICOLON\",\n\t[TokenKind.LPAREN]: \"LPAREN\",\n\t[TokenKind.RPAREN]: \"RPAREN\",\n\t[TokenKind.LESS]: \"LESS\",\n\t[TokenKind.GREAT]: \"GREAT\"\n};\n/**\n* Canonical spellings for operators and special tokens.\n*/\nconst TOKEN_SPELLINGS = new Map([\n\t[TokenKind.EOF, \"<eof>\"],\n\t[TokenKind.ERROR, \"<error>\"],\n\t[TokenKind.NEWLINE, \"\\\\n\"],\n\t[TokenKind.PIPE, \"|\"],\n\t[TokenKind.SEMICOLON, \";\"],\n\t[TokenKind.LPAREN, \"(\"],\n\t[TokenKind.RPAREN, \")\"],\n\t[TokenKind.LESS, \"<\"],\n\t[TokenKind.GREAT, \">\"]\n]);\n/**\n* Represents a single token from the lexer.\n*/\nvar Token = class Token {\n\tkind;\n\tspelling;\n\tspan;\n\tflags;\n\twordParts;\n\tconstructor(kind, spelling, span, flags = createEmptyFlags(), wordParts = []) {\n\t\tthis.kind = kind;\n\t\tthis.spelling = spelling;\n\t\tthis.span = span;\n\t\tthis.flags = flags;\n\t\tthis.wordParts = wordParts;\n\t}\n\t/**\n\t* Get the canonical spelling for a token kind.\n\t*/\n\tstatic spell(kind) {\n\t\treturn TOKEN_SPELLINGS.get(kind) ?? \"<unknown>\";\n\t}\n\t/**\n\t* Get the name of a token kind.\n\t*/\n\tstatic kindName(kind) {\n\t\treturn TOKEN_KIND_NAMES[kind] ?? \"UNKNOWN\";\n\t}\n\t/**\n\t* Check if this token is an operator.\n\t*/\n\tget isOperator() {\n\t\treturn this.kind >= TokenKind.PIPE && this.kind <= TokenKind.GREAT;\n\t}\n\t/**\n\t* Check if this token has any quote flags set.\n\t*/\n\tget isQuoted() {\n\t\treturn isQuoted(this.flags);\n\t}\n\t/**\n\t* Check if this token contains expansions (command substitution).\n\t*/\n\tget hasExpansions() {\n\t\treturn this.flags.containsExpansion || this.wordParts.some((part) => part.kind === \"commandSub\");\n\t}\n\t/**\n\t* Check if this token contains glob patterns.\n\t*/\n\tget hasGlob() {\n\t\treturn this.flags.containsGlob || this.wordParts.some((part) => part.kind === \"glob\");\n\t}\n\ttoString() {\n\t\treturn `Token(${Token.kindName(this.kind)}, \"${this.spelling}\", ${this.span})`;\n\t}\n};\n\n//#endregion\n//#region src/lexer/operators.ts\n/**\n* Multi-character operators sorted by length (longest first) for greedy matching.\n*\n* For the fish subset, we only support:\n* - | (pipe)\n* - > (output redirection - Phase 2)\n* - < (input redirection - Phase 2)\n*\n* NOT supported: &&, ||, >>, &>, >?, ;, &\n*/\nconst OPERATORS = [];\n/**\n* Single-character operators for O(1) lookup.\n*/\nconst SINGLE_CHAR_OPS = new Map([\n\t[\"|\", TokenKind.PIPE],\n\t[\";\", TokenKind.SEMICOLON],\n\t[\"<\", TokenKind.LESS],\n\t[\">\", TokenKind.GREAT]\n]);\n/**\n* Characters that are special and require careful handling.\n* These can start or affect token boundaries.\n*\n* Simplified for fish subset - no $, {, }, ~\n*/\nconst SPECIAL_CHARS = new Set([\n\t\" \",\n\t\"\t\",\n\t\"\\n\",\n\t\"|\",\n\t\";\",\n\t\"<\",\n\t\">\",\n\t\"(\",\n\t\")\",\n\t\"\\\"\",\n\t\"'\",\n\t\"\\\\\",\n\t\"*\",\n\t\"?\",\n\t\"[\",\n\t\"#\"\n]);\n/**\n* Characters that definitively end a word (token boundary).\n*/\nconst WORD_BOUNDARY_CHARS = new Set([\n\t\" \",\n\t\"\t\",\n\t\"\\n\",\n\t\"|\",\n\t\";\",\n\t\"<\",\n\t\">\",\n\t\")\",\n\t\"\\0\"\n]);\n\n//#endregion\n//#region src/lexer/source-reader.ts\n/**\n* In-memory implementation of SourceReader (fast).\n*/\nvar StringSourceReader = class StringSourceReader {\n\tstatic EOF = \"\\0\";\n\tinput;\n\tpos = 0;\n\tline = 1;\n\tcolumn = 1;\n\tmarkState = null;\n\tconstructor(input) {\n\t\tthis.input = input;\n\t}\n\tget eof() {\n\t\treturn this.pos >= this.input.length;\n\t}\n\tget position() {\n\t\treturn new SourcePosition(this.line, this.column, this.pos);\n\t}\n\tpeek(offset = 0) {\n\t\tconst idx = this.pos + offset;\n\t\tconst char = this.input[idx];\n\t\treturn char !== void 0 ? char : StringSourceReader.EOF;\n\t}\n\tadvance() {\n\t\tif (this.eof) return StringSourceReader.EOF;\n\t\tconst char = this.input[this.pos];\n\t\tif (char === void 0) return StringSourceReader.EOF;\n\t\tthis.pos++;\n\t\tif (char === \"\\n\") {\n\t\t\tthis.line++;\n\t\t\tthis.column = 1;\n\t\t} else this.column++;\n\t\treturn char;\n\t}\n\tmark() {\n\t\tthis.markState = {\n\t\t\tpos: this.pos,\n\t\t\tline: this.line,\n\t\t\tcolumn: this.column\n\t\t};\n\t}\n\treset() {\n\t\tif (this.markState) {\n\t\t\tthis.pos = this.markState.pos;\n\t\t\tthis.line = this.markState.line;\n\t\t\tthis.column = this.markState.column;\n\t\t\tthis.markState = null;\n\t\t}\n\t}\n};\n\n//#endregion\n//#region src/lexer/scanner.ts\nconst NUMBER_PATTERN = /^[0-9]+$/;\nconst NAME_PATTERN = /^[a-zA-Z_][a-zA-Z0-9_-]*$/;\n/**\n* Merge two flags objects, combining their values.\n*/\nfunction mergeFlags(a, b) {\n\treturn {\n\t\tquoted: a.quoted || b.quoted,\n\t\tsingleQuoted: a.singleQuoted || b.singleQuoted,\n\t\tdoubleQuoted: a.doubleQuoted || b.doubleQuoted,\n\t\tcontainsExpansion: a.containsExpansion || b.containsExpansion,\n\t\tcontainsGlob: a.containsGlob || b.containsGlob\n\t};\n}\n/**\n* The main Scanner class for tokenizing fish subset source code.\n*\n* This lexer implements a fish-inspired subset with:\n* - Pipelines (|)\n* - Command substitution (...)\n* - Globbing (* ? [...])\n* - Single quotes (literal, no escapes)\n* - Double quotes (command substitution allowed, minimal escaping)\n* - Comments (#)\n* - Redirection (> <) - Phase 2\n*\n* NOT supported:\n* - Variables ($var)\n* - Brace expansion ({a,b})\n* - Control flow (if, for, while, etc.)\n* - Functions\n* - Background (&)\n* - Semicolons (;)\n* - and/or/not keywords\n* - Tilde expansion (~)\n* - Recursive globbing (**)\n*/\nvar Scanner = class {\n\tsource;\n\tstateCtx = new StateContext();\n\tdebug = false;\n\tconstructor(input) {\n\t\tthis.source = typeof input === \"string\" ? new StringSourceReader(input) : input;\n\t}\n\t/**\n\t* Enable debug logging of tokens.\n\t*/\n\tenableDebugging() {\n\t\tthis.debug = true;\n\t\treturn this;\n\t}\n\t/**\n\t* Main entry: get next token.\n\t*/\n\tgetToken() {\n\t\tthis.skipWhitespace();\n\t\tconst start = this.source.position;\n\t\tconst token = this.nextToken(start);\n\t\tif (this.debug) console.log(token.toString());\n\t\treturn token;\n\t}\n\t/**\n\t* Tokenize all input.\n\t*/\n\ttokenize() {\n\t\tconst tokens = [];\n\t\tlet token;\n\t\tdo {\n\t\t\ttoken = this.getToken();\n\t\t\ttokens.push(token);\n\t\t} while (token.kind !== TokenKind.EOF);\n\t\treturn tokens;\n\t}\n\tnextToken(start) {\n\t\tconst c0 = this.source.peek();\n\t\tif (this.source.eof || c0 === \"\\0\") return this.makeToken(TokenKind.EOF, \"\", start);\n\t\tif (c0 === \"#\") return this.readComment(start);\n\t\tif (c0 === \"\\n\") {\n\t\t\tthis.source.advance();\n\t\t\treturn this.makeToken(TokenKind.NEWLINE, \"\\n\", start);\n\t\t}\n\t\tconst opToken = this.tryMatchOperator(start);\n\t\tif (opToken) return opToken;\n\t\tconst singleOp = SINGLE_CHAR_OPS.get(c0);\n\t\tif (singleOp !== void 0) {\n\t\t\tthis.source.advance();\n\t\t\treturn this.makeToken(singleOp, c0, start);\n\t\t}\n\t\tif (c0 === \"(\") return this.readWord(start);\n\t\tif (c0 === \")\") {\n\t\t\tthis.source.advance();\n\t\t\treturn this.makeToken(TokenKind.RPAREN, \")\", start);\n\t\t}\n\t\treturn this.readWord(start);\n\t}\n\ttryMatchOperator(start) {\n\t\tconst chars = this.source.peek() + this.source.peek(1);\n\t\tfor (const op of OPERATORS) if (chars.startsWith(op.pattern)) {\n\t\t\tfor (const _ of op.pattern) this.source.advance();\n\t\t\treturn this.makeToken(op.kind, op.pattern, start);\n\t\t}\n\t\treturn null;\n\t}\n\treadWord(start) {\n\t\tconst fastResult = this.tryFastPath(start);\n\t\tif (fastResult) return fastResult;\n\t\treturn this.readComplexWord(start);\n\t}\n\ttryFastPath(start) {\n\t\tthis.source.mark();\n\t\tlet spelling = \"\";\n\t\twhile (!this.source.eof) {\n\t\t\tconst c = this.source.peek();\n\t\t\tif (this.isSpecialChar(c)) break;\n\t\t\tspelling += this.source.advance();\n\t\t}\n\t\tif (spelling.length === 0) {\n\t\t\tthis.source.reset();\n\t\t\treturn null;\n\t\t}\n\t\tconst next = this.source.peek();\n\t\tif (this.isWordBoundary(next)) return this.classifyWord(spelling, start, createEmptyFlags(), [this.createWordPart(\"literal\", spelling, start.span(this.source.position))]);\n\t\tthis.source.reset();\n\t\treturn null;\n\t}\n\treadComplexWord(start) {\n\t\tthis.stateCtx.reset();\n\t\tlet spelling = \"\";\n\t\tlet flags = createEmptyFlags();\n\t\tconst wordParts = [];\n\t\twhile (!this.source.eof) {\n\t\t\tconst c = this.source.peek();\n\t\t\tif (!this.stateCtx.inQuotes && this.isWordBoundary(c) && c !== \"(\") break;\n\t\t\tconst result = this.processChar(c, this.source.position);\n\t\t\tspelling += result.chars;\n\t\t\tflags = mergeFlags(flags, result.flags);\n\t\t\tif (result.part) this.appendWordPart(wordParts, result.part);\n\t\t\tif (result.done) break;\n\t\t}\n\t\treturn this.classifyWord(spelling, start, flags, wordParts);\n\t}\n\tprocessChar(c, start) {\n\t\tif (c === \"'\" && !this.stateCtx.inDoubleQuote) return this.handleSingleQuote();\n\t\tif (c === \"\\\"\" && !this.stateCtx.inSingleQuote) return this.handleDoubleQuote();\n\t\tif (c === \"\\\\\" && !this.stateCtx.inSingleQuote) return this.handleEscape(start);\n\t\tif (c === \"(\" && !this.stateCtx.inQuotes) return this.readCommandSubstitution(start);\n\t\tif ((c === \"*\" || c === \"?\") && !this.stateCtx.inQuotes) return this.handleGlobChar(c, start);\n\t\tif (c === \"[\" && !this.stateCtx.inQuotes) return this.readCharacterClass(start);\n\t\tconst quote = this.currentWordPartQuote();\n\t\tthis.source.advance();\n\t\treturn {\n\t\t\tchars: c,\n\t\t\tflags: createEmptyFlags(),\n\t\t\tdone: false,\n\t\t\tpart: this.createWordPart(\"literal\", c, start.span(this.source.position), quote)\n\t\t};\n\t}\n\thandleGlobChar(c, start) {\n\t\tthis.source.advance();\n\t\tconst flags = createEmptyFlags();\n\t\tflags.containsGlob = true;\n\t\treturn {\n\t\t\tchars: c,\n\t\t\tflags,\n\t\t\tdone: false,\n\t\t\tpart: this.createWordPart(\"glob\", c, start.span(this.source.position))\n\t\t};\n\t}\n\thandleSingleQuote() {\n\t\tif (this.stateCtx.inSingleQuote) {\n\t\t\tthis.stateCtx.pop();\n\t\t\tthis.source.advance();\n\t\t\treturn {\n\t\t\t\tchars: \"\",\n\t\t\t\tflags: createEmptyFlags(),\n\t\t\t\tdone: false,\n\t\t\t\tpart: null\n\t\t\t};\n\t\t}\n\t\tthis.stateCtx.push(LexerState.SINGLE_QUOTED);\n\t\tthis.source.advance();\n\t\tconst flags = createEmptyFlags();\n\t\tflags.singleQuoted = true;\n\t\tflags.quoted = true;\n\t\treturn {\n\t\t\tchars: \"\",\n\t\t\tflags,\n\t\t\tdone: false,\n\t\t\tpart: null\n\t\t};\n\t}\n\thandleDoubleQuote() {\n\t\tif (this.stateCtx.inDoubleQuote) {\n\t\t\tthis.stateCtx.pop();\n\t\t\tthis.source.advance();\n\t\t\treturn {\n\t\t\t\tchars: \"\",\n\t\t\t\tflags: createEmptyFlags(),\n\t\t\t\tdone: false,\n\t\t\t\tpart: null\n\t\t\t};\n\t\t}\n\t\tthis.stateCtx.push(LexerState.DOUBLE_QUOTED);\n\t\tthis.source.advance();\n\t\tconst flags = createEmptyFlags();\n\t\tflags.doubleQuoted = true;\n\t\tflags.quoted = true;\n\t\treturn {\n\t\t\tchars: \"\",\n\t\t\tflags,\n\t\t\tdone: false,\n\t\t\tpart: null\n\t\t};\n\t}\n\thandleEscape(start) {\n\t\tconst quote = this.currentWordPartQuote();\n\t\tthis.source.advance();\n\t\tconst next = this.source.peek();\n\t\tif (this.source.eof || next === \"\\0\") return {\n\t\t\tchars: \"\\\\\",\n\t\t\tflags: createEmptyFlags(),\n\t\t\tdone: false,\n\t\t\tpart: this.createWordPart(\"literal\", \"\\\\\", start.span(this.source.position), quote)\n\t\t};\n\t\tif (next === \"\\n\") {\n\t\t\tthis.source.advance();\n\t\t\treturn {\n\t\t\t\tchars: \"\",\n\t\t\t\tflags: createEmptyFlags(),\n\t\t\t\tdone: false,\n\t\t\t\tpart: null\n\t\t\t};\n\t\t}\n\t\tif (this.stateCtx.inDoubleQuote) {\n\t\t\tif (\"\\\"\\\\\".includes(next)) {\n\t\t\t\tthis.source.advance();\n\t\t\t\treturn {\n\t\t\t\t\tchars: next,\n\t\t\t\t\tflags: createEmptyFlags(),\n\t\t\t\t\tdone: false,\n\t\t\t\t\tpart: this.createWordPart(\"literal\", next, start.span(this.source.position), quote, true)\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tchars: \"\\\\\",\n\t\t\t\tflags: createEmptyFlags(),\n\t\t\t\tdone: false,\n\t\t\t\tpart: this.createWordPart(\"literal\", \"\\\\\", start.span(this.source.position), quote)\n\t\t\t};\n\t\t}\n\t\tthis.source.advance();\n\t\treturn {\n\t\t\tchars: next,\n\t\t\tflags: createEmptyFlags(),\n\t\t\tdone: false,\n\t\t\tpart: this.createWordPart(\"literal\", next, start.span(this.source.position), quote, true)\n\t\t};\n\t}\n\treadCommandSubstitution(start) {\n\t\tconst quote = this.currentWordPartQuote();\n\t\tlet result = \"\";\n\t\tresult += this.source.advance();\n\t\tlet depth = 1;\n\t\twhile (depth > 0 && !this.source.eof) {\n\t\t\tconst c = this.source.peek();\n\t\t\tif (c === \"(\") {\n\t\t\t\tdepth++;\n\t\t\t\tresult += this.source.advance();\n\t\t\t} else if (c === \")\") {\n\t\t\t\tdepth--;\n\t\t\t\tresult += this.source.advance();\n\t\t\t} else if (c === \"'\" || c === \"\\\"\") result += this.skipQuotedContent(c);\n\t\t\telse if (c === \"\\\\\" && !this.source.eof) {\n\t\t\t\tresult += this.source.advance();\n\t\t\t\tif (!this.source.eof) result += this.source.advance();\n\t\t\t} else result += this.source.advance();\n\t\t}\n\t\tconst flags = createEmptyFlags();\n\t\tflags.containsExpansion = true;\n\t\treturn {\n\t\t\tchars: result,\n\t\t\tflags,\n\t\t\tdone: false,\n\t\t\tpart: this.createWordPart(\"commandSub\", result, start.span(this.source.position), quote)\n\t\t};\n\t}\n\treadCharacterClass(start) {\n\t\tlet result = \"\";\n\t\tresult += this.source.advance();\n\t\tif (this.source.peek() === \"!\" || this.source.peek() === \"^\") result += this.source.advance();\n\t\tif (this.source.peek() === \"]\") result += this.source.advance();\n\t\twhile (!this.source.eof && this.source.peek() !== \"]\") result += this.source.advance();\n\t\tif (this.source.peek() === \"]\") result += this.source.advance();\n\t\tconst flags = createEmptyFlags();\n\t\tflags.containsGlob = true;\n\t\treturn {\n\t\t\tchars: result,\n\t\t\tflags,\n\t\t\tdone: false,\n\t\t\tpart: this.createWordPart(\"glob\", result, start.span(this.source.position))\n\t\t};\n\t}\n\tskipQuotedContent(quoteChar) {\n\t\tlet result = \"\";\n\t\tresult += this.source.advance();\n\t\twhile (!this.source.eof && this.source.peek() !== quoteChar) {\n\t\t\tconst c = this.source.peek();\n\t\t\tresult += this.source.advance();\n\t\t\tif (c === \"\\\\\" && quoteChar === \"\\\"\" && !this.source.eof) result += this.source.advance();\n\t\t}\n\t\tif (this.source.peek() === quoteChar) result += this.source.advance();\n\t\treturn result;\n\t}\n\tclassifyWord(spelling, start, flags, wordParts) {\n\t\tconst normalizedWordParts = wordParts.length > 0 ? wordParts : [this.createWordPart(\"literal\", spelling, start.span(this.source.position), this.defaultWordPartQuote(flags))];\n\t\tif (NUMBER_PATTERN.test(spelling)) return this.makeToken(TokenKind.NUMBER, spelling, start, flags, normalizedWordParts);\n\t\tif (NAME_PATTERN.test(spelling)) return this.makeToken(TokenKind.NAME, spelling, start, flags, normalizedWordParts);\n\t\treturn this.makeToken(TokenKind.WORD, spelling, start, flags, normalizedWordParts);\n\t}\n\tskipWhitespace() {\n\t\twhile (!this.source.eof) {\n\t\t\tconst c = this.source.peek();\n\t\t\tif (c === \" \" || c === \"\t\") this.source.advance();\n\t\t\telse if (c === \"\\\\\" && this.source.peek(1) === \"\\n\") {\n\t\t\t\tthis.source.advance();\n\t\t\t\tthis.source.advance();\n\t\t\t} else break;\n\t\t}\n\t}\n\treadComment(start) {\n\t\tlet spelling = \"\";\n\t\twhile (!this.source.eof && this.source.peek() !== \"\\n\") spelling += this.source.advance();\n\t\treturn this.makeToken(TokenKind.COMMENT, spelling, start);\n\t}\n\tisSpecialChar(c) {\n\t\treturn SPECIAL_CHARS.has(c);\n\t}\n\tisWordBoundary(c) {\n\t\treturn WORD_BOUNDARY_CHARS.has(c) || c === \"\\0\";\n\t}\n\tmakeToken(kind, spelling, start, flags = createEmptyFlags(), wordParts = []) {\n\t\treturn new Token(kind, spelling, start.span(this.source.position), flags, wordParts);\n\t}\n\tcreateWordPart(kind, text, span, quote = \"none\", escaped = false) {\n\t\treturn {\n\t\t\tescaped,\n\t\t\tkind,\n\t\t\tquote,\n\t\t\tspan,\n\t\t\ttext\n\t\t};\n\t}\n\tappendWordPart(wordParts, part) {\n\t\tif (part.text === \"\") return;\n\t\tconst previousPart = wordParts.at(-1);\n\t\tif (previousPart?.kind === \"literal\" && part.kind === \"literal\" && previousPart.quote === part.quote && previousPart.escaped === part.escaped && previousPart.span.end.offset === part.span.start.offset) {\n\t\t\twordParts[wordParts.length - 1] = this.createWordPart(\"literal\", `${previousPart.text}${part.text}`, new SourceSpan(previousPart.span.start, part.span.end), part.quote, part.escaped);\n\t\t\treturn;\n\t\t}\n\t\twordParts.push(part);\n\t}\n\tcurrentWordPartQuote() {\n\t\tif (this.stateCtx.inSingleQuote) return \"single\";\n\t\tif (this.stateCtx.inDoubleQuote) return \"double\";\n\t\treturn \"none\";\n\t}\n\tdefaultWordPartQuote(flags) {\n\t\tif (flags.singleQuoted) return \"single\";\n\t\tif (flags.doubleQuoted) return \"double\";\n\t\treturn \"none\";\n\t}\n};\n\n//#endregion\n//#region src/parser/ast.ts\n/**\n* Base class for all AST nodes.\n* Every node has a source span for error reporting.\n*/\nvar ASTNode = class {\n\tspan;\n\tconstructor(span) {\n\t\tthis.span = span;\n\t}\n};\n/**\n* Root AST node representing a complete program.\n* A program is an ordered list of statements.\n*/\nvar Program = class extends ASTNode {\n\tstatements;\n\tconstructor(span, statements) {\n\t\tsuper(span);\n\t\tthis.statements = statements;\n\t}\n\taccept(visitor) {\n\t\treturn visitor.visitProgram(this);\n\t}\n};\n/**\n* A script statement containing a pipeline and chain metadata.\n* The metadata is currently structural-only and defaults to \"always\".\n*/\nvar Statement = class extends ASTNode {\n\tpipeline;\n\tchainMode;\n\tconstructor(span, pipeline, chainMode = \"always\") {\n\t\tsuper(span);\n\t\tthis.pipeline = pipeline;\n\t\tthis.chainMode = chainMode;\n\t}\n\taccept(visitor) {\n\t\treturn visitor.visitStatement(this);\n\t}\n};\n/**\n* A pipeline of one or more commands connected by pipes.\n* Example: `ls | grep foo | sort`\n*/\nvar Pipeline = class extends ASTNode {\n\tcommands;\n\tconstructor(span, commands) {\n\t\tsuper(span);\n\t\tthis.commands = commands;\n\t}\n\taccept(visitor) {\n\t\treturn visitor.visitPipeline(this);\n\t}\n};\n/**\n* A simple command with a name, arguments, and optional redirections.\n* Example: `grep -n pattern file.txt > output.txt`\n*/\nvar SimpleCommand = class extends ASTNode {\n\t/** The command name (first word) */\n\tname;\n\t/** Command arguments (remaining words) */\n\targs;\n\t/** Redirections (Phase 2) */\n\tredirections;\n\tconstructor(span, name, args, redirections = []) {\n\t\tsuper(span);\n\t\tthis.name = name;\n\t\tthis.args = args;\n\t\tthis.redirections = redirections;\n\t}\n\taccept(visitor) {\n\t\treturn visitor.visitSimpleCommand(this);\n\t}\n};\n/**\n* A word is a sequence of word parts.\n* Parts can be literals, globs, or command substitutions.\n* Example: `foo*.txt` has a literal part \"foo\", a glob part \"*\", and a literal part \".txt\"\n*/\nvar Word = class extends ASTNode {\n\tparts;\n\t/** True if the word was quoted (single or double) */\n\tquoted;\n\tconstructor(span, parts, quoted = false) {\n\t\tsuper(span);\n\t\tthis.parts = parts;\n\t\tthis.quoted = quoted;\n\t}\n\t/**\n\t* Get the literal value if this word has no expansions.\n\t* Returns null if the word contains globs or command substitutions.\n\t*/\n\tget literalValue() {\n\t\tif (this.parts.every((p) => p.kind === \"literal\")) return this.parts.map((p) => p.value).join(\"\");\n\t\treturn null;\n\t}\n\t/**\n\t* Check if this word contains any glob patterns.\n\t*/\n\tget hasGlob() {\n\t\treturn this.parts.some((p) => p.kind === \"glob\");\n\t}\n\t/**\n\t* Check if this word contains command substitution.\n\t*/\n\tget hasCommandSub() {\n\t\treturn this.parts.some((p) => p.kind === \"commandSub\");\n\t}\n\taccept(visitor) {\n\t\treturn visitor.visitWord(this);\n\t}\n};\n/**\n* A literal string part of a word.\n*/\nvar LiteralPart = class {\n\tkind = \"literal\";\n\tspan;\n\tvalue;\n\tconstructor(span, value) {\n\t\tthis.span = span;\n\t\tthis.value = value;\n\t}\n\taccept(visitor) {\n\t\treturn visitor.visitLiteralPart(this);\n\t}\n};\n/**\n* A glob pattern part of a word.\n* Examples: `*`, `?`, `[abc]`, `[a-z]`, `[!abc]`\n*/\nvar GlobPart = class {\n\tkind = \"glob\";\n\tspan;\n\tpattern;\n\tconstructor(span, pattern) {\n\t\tthis.span = span;\n\t\tthis.pattern = pattern;\n\t}\n\taccept(visitor) {\n\t\treturn visitor.visitGlobPart(this);\n\t}\n};\n/**\n* A command substitution part of a word.\n* Example: `(ls -la)`\n*\n* The inner program is parsed recursively.\n*/\nvar CommandSubPart = class {\n\tkind = \"commandSub\";\n\tspan;\n\t/** The inner program to execute */\n\tprogram;\n\tconstructor(span, program) {\n\t\tthis.span = span;\n\t\tthis.program = program;\n\t}\n\taccept(visitor) {\n\t\treturn visitor.visitCommandSubPart(this);\n\t}\n};\n/**\n* A redirection (input or output).\n* Examples: `< input.txt`, `> output.txt`\n*/\nvar Redirection = class extends ASTNode {\n\tredirectKind;\n\ttarget;\n\tconstructor(span, redirectKind, target) {\n\t\tsuper(span);\n\t\tthis.redirectKind = redirectKind;\n\t\tthis.target = target;\n\t}\n\taccept(visitor) {\n\t\treturn visitor.visitRedirection(this);\n\t}\n};\n\n//#endregion\n//#region src/parser/command.ts\n/**\n* Command parser for the Fish subset parser.\n*\n* Handles parsing of commands:\n* - Simple commands (name + args)\n* - Redirections (< > Phase 2)\n*/\n/**\n* Parser for commands.\n*\n* A command in the Fish subset is:\n* - A simple command: name followed by arguments and optional redirections\n*\n* Fish subset does NOT support:\n* - Compound commands (if, for, while, function, etc.)\n* - Background execution (&)\n* - Semicolons (;)\n*/\nvar CommandParser = class {\n\tparser;\n\twordParser;\n\tconstructor(parser, wordParser) {\n\t\tthis.parser = parser;\n\t\tthis.wordParser = wordParser;\n\t}\n\t/**\n\t* Parse a command.\n\t* Returns null if no command is present.\n\t*/\n\tparseCommand() {\n\t\treturn this.parseSimpleCommand();\n\t}\n\t/**\n\t* Parse a simple command: name + args + redirections.\n\t*\n\t* Grammar:\n\t* simple_command ::= word+ (redirection)*\n\t*/\n\tparseSimpleCommand() {\n\t\tconst startPos = this.parser.currentToken.span.start;\n\t\tconst name = this.wordParser.parseWord();\n\t\tif (!name) return null;\n\t\tconst args = [];\n\t\tconst redirections = [];\n\t\twhile (!this.isCommandTerminator()) {\n\t\t\tconst redir = this.parseRedirection();\n\t\t\tif (redir) {\n\t\t\t\tredirections.push(redir);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst word = this.wordParser.parseWord();\n\t\t\tif (word) args.push(word);\n\t\t\telse break;\n\t\t}\n\t\tconst endPos = this.parser.previousTokenPosition;\n\t\treturn new SimpleCommand(new SourceSpan(startPos, endPos), name, args, redirections);\n\t}\n\t/**\n\t* Parse a redirection if present.\n\t*\n\t* Grammar:\n\t* redirection ::= '<' word | '>' word | '>>' word\n\t*/\n\tparseRedirection() {\n\t\tconst token = this.parser.currentToken;\n\t\tif (token.kind === TokenKind.LESS) {\n\t\t\tconst startPos = token.span.start;\n\t\t\tthis.parser.advance();\n\t\t\tconst target = this.wordParser.parseWord();\n\t\t\tif (!target) {\n\t\t\t\tthis.parser.syntacticError(\"Expected filename after <\", \"word\");\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst endPos = this.parser.previousTokenPosition;\n\t\t\treturn new Redirection(new SourceSpan(startPos, endPos), \"input\", target);\n\t\t}\n\t\tif (token.kind === TokenKind.GREAT) {\n\t\t\tconst startPos = token.span.start;\n\t\t\tthis.parser.advance();\n\t\t\tif (this.parser.currentToken.kind === TokenKind.GREAT) this.parser.advance();\n\t\t\tconst target = this.wordParser.parseWord();\n\t\t\tif (!target) {\n\t\t\t\tthis.parser.syntacticError(\"Expected filename after >\", \"word\");\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\tconst endPos = this.parser.previousTokenPosition;\n\t\t\treturn new Redirection(new SourceSpan(startPos, endPos), \"output\", target);\n\t\t}\n\t\treturn null;\n\t}\n\t/**\n\t* Check if current token terminates a command.\n\t*/\n\tisCommandTerminator() {\n\t\tconst kind = this.parser.currentToken.kind;\n\t\treturn kind === TokenKind.PIPE || kind === TokenKind.SEMICOLON || kind === TokenKind.NEWLINE || kind === TokenKind.EOF;\n\t}\n};\n\n//#endregion\n//#region src/parser/error-reporter.ts\n/**\n* Error reporter for collecting parser diagnostics.\n*\n* Supports both immediate error throwing and error collection modes.\n*/\nvar ErrorReporter = class {\n\tdiagnostics = [];\n\terrorCount = 0;\n\twarningCount = 0;\n\t/**\n\t* Report an error.\n\t*/\n\treportError(message, span, code) {\n\t\tthis.diagnostics.push({\n\t\t\tseverity: \"error\",\n\t\t\tmessage,\n\t\t\tspan,\n\t\t\tcode\n\t\t});\n\t\tthis.errorCount++;\n\t}\n\t/**\n\t* Report a warning.\n\t*/\n\treportWarning(message, span, code) {\n\t\tthis.diagnostics.push({\n\t\t\tseverity: \"warning\",\n\t\t\tmessage,\n\t\t\tspan,\n\t\t\tcode\n\t\t});\n\t\tthis.warningCount++;\n\t}\n\t/**\n\t* Report an informational message.\n\t*/\n\treportInfo(message, span, code) {\n\t\tthis.diagnostics.push({\n\t\t\tseverity: \"info\",\n\t\t\tmessage,\n\t\t\tspan,\n\t\t\tcode\n\t\t});\n\t}\n\t/**\n\t* Check if any errors have been reported.\n\t*/\n\thasErrors() {\n\t\treturn this.errorCount > 0;\n\t}\n\t/**\n\t* Check if any warnings have been reported.\n\t*/\n\thasWarnings() {\n\t\treturn this.warningCount > 0;\n\t}\n\t/**\n\t* Get the number of errors.\n\t*/\n\tgetErrorCount() {\n\t\treturn this.errorCount;\n\t}\n\t/**\n\t* Get the number of warnings.\n\t*/\n\tgetWarningCount() {\n\t\treturn this.warningCount;\n\t}\n\t/**\n\t* Get all diagnostics.\n\t*/\n\tgetDiagnostics() {\n\t\treturn this.diagnostics;\n\t}\n\t/**\n\t* Get only error diagnostics.\n\t*/\n\tgetErrors() {\n\t\treturn this.diagnostics.filter((d) => d.severity === \"error\");\n\t}\n\t/**\n\t* Get only warning diagnostics.\n\t*/\n\tgetWarnings() {\n\t\treturn this.diagnostics.filter((d) => d.severity === \"warning\");\n\t}\n\t/**\n\t* Clear all diagnostics.\n\t*/\n\tclear() {\n\t\tthis.diagnostics.length = 0;\n\t\tthis.errorCount = 0;\n\t\tthis.warningCount = 0;\n\t}\n\t/**\n\t* Format all diagnostics as a string for display.\n\t*/\n\tformat() {\n\t\treturn this.diagnostics.map((d) => {\n\t\t\tconst loc = `${d.span.start.line}:${d.span.start.column}`;\n\t\t\tlet prefix;\n\t\t\tif (d.severity === \"error\") prefix = \"Error\";\n\t\t\telse if (d.severity === \"warning\") prefix = \"Warning\";\n\t\t\telse prefix = \"Info\";\n\t\t\tconst code = d.code ? ` [${d.code}]` : \"\";\n\t\t\treturn `${prefix}${code} at ${loc}: ${d.message}`;\n\t\t}).join(\"\\n\");\n\t}\n};\n\n//#endregion\n//#region src/parser/statement.ts\n/**\n* Statement parser for the Fish subset parser.\n*\n* Handles parsing of:\n* - Script statements separated by newline or semicolon\n* - Pipelines (command | command | ...)\n*/\n/**\n* Parser for statements and pipelines.\n*\n* In this subset, a program is an ordered list of statements.\n*/\nvar StatementParser = class {\n\tparser;\n\tcommandParser;\n\tconstructor(parser, commandParser) {\n\t\tthis.parser = parser;\n\t\tthis.commandParser = commandParser;\n\t}\n\t/**\n\t* Parse a full script program.\n\t*/\n\tparseScript() {\n\t\tconst startPos = this.parser.currentToken.span.start;\n\t\tconst statements = [];\n\t\tthis.consumeSeparatorsAndComments();\n\t\twhile (this.parser.currentToken.kind !== TokenKind.EOF) {\n\t\t\tconst statement = this.parseStatement();\n\t\t\tif (!statement) this.parser.syntacticError(\"Expected command\", \"command\");\n\t\t\tstatements.push(statement);\n\t\t\tconst sawSeparator = this.consumeSeparatorsAndComments();\n\t\t\tif (this.parser.currentToken.kind !== TokenKind.EOF && !sawSeparator) this.parser.syntacticError(\"Expected statement separator\", \"newline or ;\");\n\t\t}\n\t\tconst endPos = this.parser.previousTokenPosition;\n\t\treturn new Program(new SourceSpan(startPos, endPos), statements);\n\t}\n\t/**\n\t* Parse a single statement.\n\t*/\n\tparseStatement() {\n\t\tlet chainMode = \"always\";\n\t\tconst currentToken = this.parser.currentToken;\n\t\tif (!currentToken.isQuoted && this.isChainKeyword(currentToken.spelling)) {\n\t\t\tchainMode = currentToken.spelling === \"and\" ? \"and\" : \"or\";\n\t\t\tthis.parser.advance();\n\t\t}\n\t\tconst pipeline = this.parsePipeline();\n\t\tif (!pipeline) return null;\n\t\treturn new Statement(pipeline.span, pipeline, chainMode);\n\t}\n\t/**\n\t* Parse a pipeline.\n\t*\n\t* Grammar:\n\t* pipeline ::= command ('|' command)*\n\t*/\n\tparsePipeline() {\n\t\tconst startPos = this.parser.currentToken.span.start;\n\t\tconst firstCommand = this.commandParser.parseCommand();\n\t\tif (!firstCommand) return null;\n\t\tconst commands = [firstCommand];\n\t\twhile (this.parser.currentToken.kind === TokenKind.PIPE) {\n\t\t\tthis.parser.advance();\n\t\t\tthis.skipNewlines();\n\t\t\tconst command = this.commandParser.parseCommand();\n\t\t\tif (!command) {\n\t\t\t\tthis.parser.syntacticError(\"Expected command after |\", \"command\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcommands.push(command);\n\t\t}\n\t\tconst endPos = this.parser.previousTokenPosition;\n\t\treturn new Pipeline(new SourceSpan(startPos, endPos), commands);\n\t}\n\t/**\n\t* Skip newline tokens (for line continuation after pipe).\n\t*/\n\tskipNewlines() {\n\t\twhile (this.parser.currentToken.kind === TokenKind.NEWLINE) this.parser.advance();\n\t}\n\t/**\n\t* Consume separators and comments between statements.\n\t*\n\t* @returns true if at least one statement separator was consumed.\n\t*/\n\tconsumeSeparatorsAndComments() {\n\t\tlet sawSeparator = false;\n\t\twhile (true) {\n\t\t\tconst tokenKind = this.parser.currentToken.kind;\n\t\t\tif (tokenKind === TokenKind.COMMENT) {\n\t\t\t\tthis.parser.advance();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (tokenKind === TokenKind.NEWLINE || tokenKind === TokenKind.SEMICOLON) {\n\t\t\t\tsawSeparator = true;\n\t\t\t\tthis.parser.advance();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn sawSeparator;\n\t\t}\n\t}\n\tisChainKeyword(spelling) {\n\t\treturn spelling === \"and\" || spelling === \"or\";\n\t}\n};\n\n//#endregion\n//#region src/parser/syntax-error.ts\n/**\n* Exception thrown when a syntax error is encountered during parsing.\n*/\nvar ParseSyntaxError = class ParseSyntaxError extends Error {\n\t/** The source span where the error occurred */\n\tspan;\n\t/** Additional context about the error */\n\tcontext;\n\tconstructor(message, span, context) {\n\t\tsuper(ParseSyntaxError.formatMessage(message, span, context));\n\t\tthis.name = \"ParseSyntaxError\";\n\t\tthis.span = span;\n\t\tthis.context = context;\n\t\tif (Error.captureStackTrace) Error.captureStackTrace(this, ParseSyntaxError);\n\t}\n\t/**\n\t* Format an error message with position information.\n\t*/\n\tstatic formatMessage(message, span, context) {\n\t\tconst base = `Syntax error at ${`${span.start.line}:${span.start.column}`}: ${message}`;\n\t\treturn context ? `${base} (${context})` : base;\n\t}\n\t/**\n\t* Get the line number where the error occurred.\n\t*/\n\tget line() {\n\t\treturn this.span.start.line;\n\t}\n\t/**\n\t* Get the column number where the error occurred.\n\t*/\n\tget column() {\n\t\treturn this.span.start.column;\n\t}\n};\n/**\n* Exception thrown when the parser encounters an unexpected end of input.\n*/\nvar UnexpectedEOFError = class extends ParseSyntaxError {\n\tconstructor(expected, span) {\n\t\tsuper(`Unexpected end of input, expected ${expected}`, span);\n\t\tthis.name = \"UnexpectedEOFError\";\n\t}\n};\n/**\n* Exception thrown when the parser encounters an unexpected token.\n*/\nvar UnexpectedTokenError = class extends ParseSyntaxError {\n\tfound;\n\texpected;\n\tconstructor(found, expected, span) {\n\t\tsuper(`Unexpected token '${found}', expected ${expected}`, span);\n\t\tthis.name = \"UnexpectedTokenError\";\n\t\tthis.found = found;\n\t\tthis.expected = expected;\n\t}\n};\n\n//#endregion\n//#region src/parser/word.ts\n/**\n* Word parser for the Fish subset parser.\n*\n* Handles parsing of words and their components:\n* - Literal text\n* - Glob patterns (* ? [...])\n* - Command substitution (...)\n* - Quoted strings\n*/\n/**\n* Parser for words and word parts.\n*\n* A word can consist of:\n* - Literal parts (plain text)\n* - Glob parts (* ? [...])\n* - Command substitution parts (...)\n*/\nvar WordParser = class {\n\tparser;\n\tconstructor(parser) {\n\t\tthis.parser = parser;\n\t}\n\t/**\n\t* Parse a single word from the current position.\n\t* Returns null if no word is present.\n\t*\n\t* A word consists of a single token from the scanner.\n\t* The token may contain multiple parts (literal, glob, command substitution)\n\t* which are parsed and combined into a single Word AST node.\n\t*/\n\tparseWord() {\n\t\tconst token = this.parser.currentToken;\n\t\tif (!this.isWordToken(token)) return null;\n\t\tconst startPos = token.span.start;\n\t\tconst parts = this.parseWordParts(token);\n\t\tif (parts.length === 0) return null;\n\t\tthis.parser.advance();\n\t\tconst endPos = token.span.end;\n\t\tconst span = new SourceSpan(startPos, endPos);\n\t\tconst quoted = token.isQuoted;\n\t\treturn new Word(span, parts, quoted);\n\t}\n\t/**\n\t* Parse ordered word parts from token metadata.\n\t*/\n\tparseWordParts(token) {\n\t\treturn (token.wordParts.length > 0 ? token.wordParts : [{\n\t\t\tescaped: false,\n\t\t\tkind: \"literal\",\n\t\t\tquote: \"none\",\n\t\t\tspan: token.span,\n\t\t\ttext: token.spelling\n\t\t}]).map((part) => this.parseTokenWordPart(part));\n\t}\n\t/**\n\t* Parse a single token word part into an AST part.\n\t*/\n\tparseTokenWordPart(part) {\n\t\tswitch (part.kind) {\n\t\t\tcase \"literal\": return new LiteralPart(part.span, part.text);\n\t\t\tcase \"glob\": return new GlobPart(part.span, part.text);\n\t\t\tcase \"commandSub\": return this.parseCommandSubstitution(part.text, part.span);\n\t\t\tdefault: {\n\t\t\t\tconst _exhaustive = part;\n\t\t\t\tthrow new Error(`Unknown token word part: ${JSON.stringify(_exhaustive)}`);\n\t\t\t}\n\t\t}\n\t}\n\t/**\n\t* Parse a command substitution from token part metadata.\n\t* The part text contains the full (...) content.\n\t*/\n\tparseCommandSubstitution(spelling, span) {\n\t\tlet inner = spelling;\n\t\tif (inner.startsWith(\"(\") && inner.endsWith(\")\")) inner = inner.slice(1, -1);\n\t\treturn new CommandSubPart(span, this.parser.parseSubstitution(inner));\n\t}\n\t/**\n\t* Check if a token can be part of a word.\n\t*/\n\tisWordToken(token) {\n\t\tconst kind = token.kind;\n\t\treturn kind === TokenKind.WORD || kind === TokenKind.NAME || kind === TokenKind.NUMBER;\n\t}\n};\n\n//#endregion\n//#region src/parser/parser.ts\n/**\n* Main parser for the Fish subset language.\n*\n* This is a modular, recursive descent (LL-style) parser inspired by\n* the VC Parser architecture. It uses single-token lookahead (LL(1))\n* and streams tokens from the lexer.\n*\n* The parser delegates to sub-parsers:\n* - StatementParser: pipelines\n* - CommandParser: simple commands\n* - WordParser: words and expansions\n*\n* Fish subset features supported:\n* - Pipelines (|)\n* - Multi-statement scripts (newline and ;)\n* - Command substitution (...)\n* - Globbing (* ? [...])\n* - Redirections (< >) - Phase 2\n* - Comments (#)\n*\n* NOT supported:\n* - Variables ($var)\n* - Control flow (if, for, while, etc.)\n* - Functions\n* - Brace expansion\n* - Background jobs (&)\n*/\n/**\n* Main parser class for the Fish subset language.\n*\n* Usage:\n* ```typescript\n* const parser = new Parser('ls | grep foo');\n* const ast = parser.parse();\n* ```\n*/\nvar Parser = class Parser {\n\t/** The scanner/lexer for tokenization */\n\tscanner;\n\t/** Error reporter for collecting diagnostics */\n\terrorReporter;\n\t/** Current token being examined */\n\t_currentToken;\n\t/** Position of the previous token (for span tracking) */\n\t_previousTokenPosition;\n\t/** Sub-parsers */\n\twordParser;\n\tcommandParser;\n\tstatementParser;\n\t/** Recursion depth for command substitution */\n\tsubstitutionDepth;\n\t/** Maximum recursion depth */\n\tstatic MAX_SUBSTITUTION_DEPTH = 10;\n\tconstructor(input, errorReporter, depth = 0) {\n\t\tthis.scanner = typeof input === \"string\" ? new Scanner(input) : input;\n\t\tthis.errorReporter = errorReporter ?? new ErrorReporter();\n\t\tthis.substitutionDepth = depth;\n\t\tthis._currentToken = this.scanner.getToken();\n\t\tthis._previousTokenPosition = this._currentToken.span.start;\n\t\tthis.wordParser = new WordParser(this);\n\t\tthis.commandParser = new CommandParser(this, this.wordParser);\n\t\tthis.statementParser = new StatementParser(this, this.commandParser);\n\t}\n\t/**\n\t* Parse the input and return a Program AST.\n\t* @throws SyntaxError if the input is invalid\n\t*/\n\tparse() {\n\t\treturn this.parseProgram();\n\t}\n\t/**\n\t* Get the error reporter for accessing diagnostics.\n\t*/\n\tgetErrorReporter() {\n\t\treturn this.errorReporter;\n\t}\n\t/**\n\t* Get the current token.\n\t*/\n\tget currentToken() {\n\t\treturn this._currentToken;\n\t}\n\t/**\n\t* Get the position of the previous token.\n\t*/\n\tget previousTokenPosition() {\n\t\treturn this._previousTokenPosition;\n\t}\n\t/**\n\t* Advance to the next token.\n\t*/\n\tadvance() {\n\t\tthis._previousTokenPosition = this._currentToken.span.end;\n\t\tthis._currentToken = this.scanner.getToken();\n\t}\n\t/**\n\t* Match the current token against an expected kind.\n\t* Advances if matched, throws error if not.\n\t*\n\t* @param expected The expected token kind\n\t* @throws SyntaxError if the current token doesn't match\n\t*/\n\tmatch(expected) {\n\t\tif (this._currentToken.kind === expected) {\n\t\t\tthis._previousTokenPosition = this._currentToken.span.end;\n\t\t\tthis._currentToken = this.scanner.getToken();\n\t\t} else this.syntacticError(`Expected ${Token.kindName(expected)}`, Token.kindName(expected));\n\t}\n\t/**\n\t* Accept a token if it matches the expected kind.\n\t* Returns true and advances if matched, false otherwise.\n\t*\n\t* @param expected The expected token kind\n\t* @returns true if the token was accepted\n\t*/\n\taccept(expected) {\n\t\tif (this._currentToken.kind === expected) {\n\t\t\tthis._previousTokenPosition = this._currentToken.span.end;\n\t\t\tthis._currentToken = this.scanner.getToken();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\t/**\n\t* Check if the current token matches the expected kind.\n\t* Does not advance.\n\t*\n\t* @param expected The expected token kind\n\t* @returns true if the current token matches\n\t*/\n\tcheck(expected) {\n\t\treturn this._currentToken.kind === expected;\n\t}\n\t/**\n\t* Start tracking a span from the current token position.\n\t*/\n\tstartSpan() {\n\t\treturn this._currentToken.span.start;\n\t}\n\t/**\n\t* Finish a span at the previous token position.\n\t*/\n\tfinishSpan(start) {\n\t\treturn new SourceSpan(start, this._previousTokenPosition);\n\t}\n\t/**\n\t* Report a syntactic error and throw an exception.\n\t*\n\t* @param message Error message\n\t* @param expected What was expected (for error context)\n\t* @throws SyntaxError always\n\t*/\n\tsyntacticError(message, expected) {\n\t\tconst span = this._currentToken.span;\n\t\tthis.errorReporter.reportError(message, span);\n\t\tif (this._currentToken.kind === TokenKind.EOF) throw new UnexpectedEOFError(expected, span);\n\t\tthrow new UnexpectedTokenError(this._currentToken.spelling || Token.kindName(this._currentToken.kind), expected, span);\n\t}\n\t/**\n\t* Parse a complete program.\n\t*\n\t* Grammar:\n\t* program ::= (statement separator*)? statement (separator+ statement)* separator*\n\t*/\n\tparseProgram() {\n\t\treturn this.statementParser.parseScript();\n\t}\n\t/**\n\t* Parse a command substitution (inner program).\n\t* Called recursively when parsing (...) content.\n\t*\n\t* @param input The inner content of the command substitution\n\t* @returns The parsed program\n\t*/\n\tparseSubstitution(input) {\n\t\tif (this.substitutionDepth >= Parser.MAX_SUBSTITUTION_DEPTH) throw new ParseSyntaxError(\"Maximum command substitution depth exceeded\", this._currentToken.span);\n\t\treturn new Parser(input, this.errorReporter, this.substitutionDepth + 1).parse();\n\t}\n};\n/**\n* Parse a Fish subset input string and return the AST.\n*\n* @param input The input string to parse\n* @returns The parsed Program AST\n* @throws SyntaxError if the input is invalid\n*/\nfunction parse(input) {\n\treturn new Parser(input).parse();\n}\n\n//#endregion\nexport { Parser, cmd, commandSub, compile, compound, expandedWordHasCommandSub, expandedWordHasGlob, expandedWordParts, expandedWordToString, extractPathsFromExpandedWords, glob, literal, parse };","export interface FileRecord {\n\tkind: 'file';\n\tisDirectory?: boolean;\n\tpath: string;\n\tdisplayPath?: string;\n}\nexport interface LineRecord {\n\tkind: 'line';\n\ttext: string;\n\tfile?: string;\n\tlineNum?: number;\n}\nexport interface JsonRecord {\n\tkind: 'json';\n\tvalue: unknown;\n}\n\n/**\n * Record is the unit of data flowing through pipelines.\n * Commands operate on records, not bytes.\n */\nexport type Record = FileRecord | LineRecord | JsonRecord;\n\nexport function formatRecord(record: Record): string {\n\tswitch (record.kind) {\n\t\tcase 'line':\n\t\t\treturn record.text;\n\t\tcase 'file':\n\t\t\treturn record.displayPath ?? record.path;\n\t\tcase 'json':\n\t\t\treturn JSON.stringify(record.value);\n\t\tdefault:\n\t\t\tthrow new Error('Unknown record kind');\n\t}\n}\n","import {\n\tcompile,\n\ttype ExpandedWord,\n\ttype ExpandedWordPart,\n\texpandedWordHasGlob,\n\texpandedWordParts,\n\tparse,\n} from '@shfs/compiler';\n\nimport picomatch from 'picomatch';\nimport type { BuiltinContext } from '../builtin/types';\nimport type { FS } from '../fs/fs';\nimport { formatRecord, type Record as ShellRecord } from '../record';\n\ninterface FsEntry {\n\tpath: string;\n\tisDirectory: boolean;\n}\n\ntype NestedExecuteResult =\n\t| { kind: 'stream'; value: AsyncIterable<ShellRecord> }\n\t| { kind: 'sink'; value: Promise<void> };\n\nconst MULTIPLE_SLASH_REGEX = /\\/+/g;\nconst ROOT_DIRECTORY = '/';\nconst TRAILING_SLASH_REGEX = /\\/+$/;\nconst VARIABLE_REFERENCE_REGEX = /\\$([A-Za-z_][A-Za-z0-9_]*)/g;\nconst NO_GLOB_MATCH_MESSAGE = 'no matches found';\n\nasync function collectOutputRecords(\n\tresult: NestedExecuteResult\n): Promise<string[]> {\n\tif (result.kind === 'sink') {\n\t\tawait result.value;\n\t\treturn [];\n\t}\n\n\tconst outputs: string[] = [];\n\tfor await (const record of result.value) {\n\t\toutputs.push(formatRecord(record));\n\t}\n\treturn outputs;\n}\n\nasync function evaluateCommandSubstitution(\n\tcommand: string,\n\tfs: FS,\n\tcontext: BuiltinContext\n): Promise<string> {\n\tconst parsed = parse(command);\n\tconst nestedIR = compile(parsed);\n\tconst executeModule = await import('./execute');\n\tconst result = executeModule.execute(nestedIR, fs, context);\n\tconst outputs = await collectOutputRecords(result);\n\treturn outputs.join('\\n');\n}\n\nfunction resolveVariable(\n\tvariableName: string,\n\tcontext: BuiltinContext\n): string {\n\tif (variableName === 'status') {\n\t\treturn String(context.status);\n\t}\n\treturn (\n\t\tcontext.localVars.get(variableName) ??\n\t\tcontext.globalVars.get(variableName) ??\n\t\t''\n\t);\n}\n\nfunction expandVariables(input: string, context: BuiltinContext): string {\n\treturn input.replace(VARIABLE_REFERENCE_REGEX, (_full, variableName) => {\n\t\treturn resolveVariable(variableName, context);\n\t});\n}\n\nexport function normalizeAbsolutePath(path: string): string {\n\tconst withLeadingSlash = path.startsWith(ROOT_DIRECTORY)\n\t\t? path\n\t\t: `${ROOT_DIRECTORY}${path}`;\n\tconst singleSlashes = withLeadingSlash.replace(MULTIPLE_SLASH_REGEX, '/');\n\tconst segments = singleSlashes.split(ROOT_DIRECTORY);\n\tconst normalizedSegments: string[] = [];\n\tfor (const segment of segments) {\n\t\tif (segment === '' || segment === '.') {\n\t\t\tcontinue;\n\t\t}\n\t\tif (segment === '..') {\n\t\t\tnormalizedSegments.pop();\n\t\t\tcontinue;\n\t\t}\n\t\tnormalizedSegments.push(segment);\n\t}\n\tconst normalizedPath = `${ROOT_DIRECTORY}${normalizedSegments.join(ROOT_DIRECTORY)}`;\n\treturn normalizedPath === '' ? ROOT_DIRECTORY : normalizedPath;\n}\n\nexport function normalizeCwd(cwd: string): string {\n\tif (cwd === '') {\n\t\treturn ROOT_DIRECTORY;\n\t}\n\tconst normalized = normalizeAbsolutePath(cwd);\n\tconst trimmed = normalized.replace(TRAILING_SLASH_REGEX, '');\n\treturn trimmed === '' ? ROOT_DIRECTORY : trimmed;\n}\n\nexport function resolvePathFromCwd(cwd: string, path: string): string {\n\tif (path === '') {\n\t\treturn cwd;\n\t}\n\tif (path.startsWith(ROOT_DIRECTORY)) {\n\t\treturn normalizeAbsolutePath(path);\n\t}\n\treturn normalizeAbsolutePath(`${cwd}/${path}`);\n}\n\nexport function resolvePathsFromCwd(cwd: string, paths: string[]): string[] {\n\treturn paths.map((path) => resolvePathFromCwd(cwd, path));\n}\n\nasync function listFilesystemEntries(fs: FS): Promise<FsEntry[]> {\n\treturn await walkFilesystemEntries(fs);\n}\n\nasync function readDirectoryPaths(\n\tfs: FS,\n\tdirectoryPath: string\n): Promise<string[]> {\n\tconst children: string[] = [];\n\tfor await (const childPath of fs.readdir(directoryPath)) {\n\t\tchildren.push(childPath);\n\t}\n\tchildren.sort((left, right) => left.localeCompare(right));\n\treturn children;\n}\n\nexport async function walkFilesystemEntries(\n\tfs: FS,\n\trootDir = ROOT_DIRECTORY\n): Promise<FsEntry[]> {\n\tconst normalizedRoot = normalizeAbsolutePath(rootDir);\n\tconst rootStat = await fs.stat(normalizedRoot);\n\tif (!rootStat.isDirectory) {\n\t\tthrow new Error(`Not a directory: ${normalizedRoot}`);\n\t}\n\n\tconst entries: FsEntry[] = [];\n\tconst pendingDirectories: string[] = [normalizedRoot];\n\n\twhile (pendingDirectories.length > 0) {\n\t\tconst currentDirectory = pendingDirectories.pop();\n\t\tif (!currentDirectory) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst children = await readDirectoryPaths(fs, currentDirectory);\n\t\tfor (const childPath of children) {\n\t\t\tconst stat = await fs.stat(childPath);\n\t\t\tentries.push({\n\t\t\t\tpath: childPath,\n\t\t\t\tisDirectory: stat.isDirectory,\n\t\t\t});\n\t\t\tif (stat.isDirectory) {\n\t\t\t\tpendingDirectories.push(childPath);\n\t\t\t}\n\t\t}\n\t}\n\n\tentries.sort((left, right) => left.path.localeCompare(right.path));\n\treturn entries;\n}\n\nfunction toRelativePathFromCwd(path: string, cwd: string): string | null {\n\tif (cwd === ROOT_DIRECTORY) {\n\t\tif (path === ROOT_DIRECTORY) {\n\t\t\treturn null;\n\t\t}\n\t\treturn path.startsWith(ROOT_DIRECTORY) ? path.slice(1) : path;\n\t}\n\tif (path === cwd) {\n\t\treturn null;\n\t}\n\tconst prefix = `${cwd}${ROOT_DIRECTORY}`;\n\tif (!path.startsWith(prefix)) {\n\t\treturn null;\n\t}\n\treturn path.slice(prefix.length);\n}\n\nfunction toGlobCandidate(\n\tentry: FsEntry,\n\tcwd: string,\n\tisAbsolutePattern: boolean,\n\tdirectoryOnly: boolean\n): string | null {\n\tif (directoryOnly && !entry.isDirectory) {\n\t\treturn null;\n\t}\n\n\tconst basePath = isAbsolutePattern\n\t\t? entry.path\n\t\t: toRelativePathFromCwd(entry.path, cwd);\n\tif (!basePath || basePath === '') {\n\t\treturn null;\n\t}\n\n\tif (directoryOnly) {\n\t\treturn `${basePath}${ROOT_DIRECTORY}`;\n\t}\n\treturn basePath;\n}\n\nasync function expandGlobPattern(\n\tpattern: string,\n\tfs: FS,\n\tcontext: BuiltinContext\n): Promise<string[]> {\n\tconst directoryOnly = pattern.endsWith(ROOT_DIRECTORY);\n\tconst isAbsolutePattern = pattern.startsWith(ROOT_DIRECTORY);\n\tconst matcher = picomatch(pattern, { bash: true, dot: false });\n\tconst entries = await listFilesystemEntries(fs);\n\tconst matches: string[] = [];\n\n\tfor (const entry of entries) {\n\t\tconst candidate = toGlobCandidate(\n\t\t\tentry,\n\t\t\tcontext.cwd,\n\t\t\tisAbsolutePattern,\n\t\t\tdirectoryOnly\n\t\t);\n\t\tif (!candidate) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (matcher(candidate)) {\n\t\t\tmatches.push(candidate);\n\t\t}\n\t}\n\n\tmatches.sort((left, right) => left.localeCompare(right));\n\treturn matches;\n}\n\nfunction expectSingleExpandedPath(\n\tcommand: string,\n\texpectation: string,\n\tvalues: string[],\n\tallowEmpty = false\n): string {\n\tif (values.length !== 1) {\n\t\tthrow new Error(`${command}: ${expectation}, got ${values.length}`);\n\t}\n\n\tconst resolvedValue = values.at(0);\n\tif (resolvedValue === undefined) {\n\t\tthrow new Error(`${command}: path missing after expansion`);\n\t}\n\tif (!allowEmpty && resolvedValue === '') {\n\t\tthrow new Error(`${command}: ${expectation}, got empty path`);\n\t}\n\treturn resolvedValue;\n}\n\nexport async function evaluateExpandedPathWords(\n\tcommand: string,\n\twords: ExpandedWord[],\n\tfs: FS,\n\tcontext: BuiltinContext\n): Promise<string[]> {\n\tconst resolvedWords: string[] = [];\n\tfor (const word of words) {\n\t\tconst values = await evaluateExpandedPathWord(\n\t\t\tcommand,\n\t\t\tword,\n\t\t\tfs,\n\t\t\tcontext\n\t\t);\n\t\tresolvedWords.push(...values);\n\t}\n\treturn resolvedWords;\n}\n\nexport async function evaluateExpandedPathWord(\n\tcommand: string,\n\tword: ExpandedWord,\n\tfs: FS,\n\tcontext: BuiltinContext\n): Promise<string[]> {\n\tif (!expandedWordHasGlob(word)) {\n\t\treturn [await evaluateExpandedWord(word, fs, context)];\n\t}\n\n\tconst patternSegments: string[] = [];\n\tfor (const part of expandedWordParts(word)) {\n\t\tpatternSegments.push(await evaluateExpandedWordPart(part, fs, context));\n\t}\n\n\tconst pattern = patternSegments.join('');\n\tconst matches = await expandGlobPattern(pattern, fs, context);\n\tif (matches.length === 0) {\n\t\tthrow new Error(`${command}: ${NO_GLOB_MATCH_MESSAGE}: ${pattern}`);\n\t}\n\treturn matches;\n}\n\nexport async function evaluateExpandedSinglePath(\n\tcommand: string,\n\texpectation: string,\n\tword: ExpandedWord,\n\tfs: FS,\n\tcontext: BuiltinContext,\n\toptions?: { allowEmpty?: boolean }\n): Promise<string> {\n\treturn expectSingleExpandedPath(\n\t\tcommand,\n\t\texpectation,\n\t\tawait evaluateExpandedPathWord(command, word, fs, context),\n\t\toptions?.allowEmpty ?? false\n\t);\n}\n\nexport async function evaluateExpandedWords(\n\twords: ExpandedWord[],\n\tfs: FS,\n\tcontext: BuiltinContext\n): Promise<string[]> {\n\tconst resolvedWords: string[] = [];\n\tfor (const word of words) {\n\t\tresolvedWords.push(await evaluateExpandedWord(word, fs, context));\n\t}\n\treturn resolvedWords;\n}\n\nexport async function evaluateExpandedWord(\n\tword: ExpandedWord,\n\tfs: FS,\n\tcontext: BuiltinContext\n): Promise<string> {\n\tconst segments: string[] = [];\n\tfor (const part of expandedWordParts(word)) {\n\t\tsegments.push(await evaluateExpandedWordPart(part, fs, context));\n\t}\n\treturn segments.join('');\n}\n\nasync function evaluateExpandedWordPart(\n\tpart: ExpandedWordPart,\n\tfs: FS,\n\tcontext: BuiltinContext\n): Promise<string> {\n\tswitch (part.kind) {\n\t\tcase 'literal':\n\t\t\treturn expandVariables(part.value, context);\n\t\tcase 'glob':\n\t\t\treturn expandVariables(part.pattern, context);\n\t\tcase 'commandSub': {\n\t\t\tconst commandText = expandVariables(part.command, context);\n\t\t\treturn await evaluateCommandSubstitution(commandText, fs, context);\n\t\t}\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = part;\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown word kind: ${JSON.stringify(_exhaustive)}`\n\t\t\t);\n\t\t}\n\t}\n}\n","import type { CdStep } from '@shfs/compiler';\nimport {\n\tevaluateExpandedSinglePath,\n\tresolvePathFromCwd,\n} from '../../execute/path';\nimport type { EffectBuiltin } from '../types';\n\nexport const cd: EffectBuiltin<CdStep['args']> = async (runtime, args) => {\n\tconst requestedPath = await evaluateExpandedSinglePath(\n\t\t'cd',\n\t\t'expected exactly 1 path after expansion',\n\t\targs.path,\n\t\truntime.fs,\n\t\truntime.context,\n\t\t{ allowEmpty: true }\n\t);\n\tif (requestedPath === '') {\n\t\tthrow new Error('cd: empty path');\n\t}\n\n\tconst resolvedPath = resolvePathFromCwd(runtime.context.cwd, requestedPath);\n\tlet stat: Awaited<ReturnType<typeof runtime.fs.stat>>;\n\ttry {\n\t\tstat = await runtime.fs.stat(resolvedPath);\n\t} catch {\n\t\tthrow new Error(`cd: directory does not exist: ${requestedPath}`);\n\t}\n\n\tif (!stat.isDirectory) {\n\t\tthrow new Error(`cd: not a directory: ${requestedPath}`);\n\t}\n\n\truntime.context.cwd = resolvedPath;\n\truntime.context.status = 0;\n};\n","import type { EchoStep } from '@shfs/compiler';\nimport { evaluateExpandedPathWords } from '../../execute/path';\nimport type { Builtin } from '../types';\n\nexport const echo: Builtin<EchoStep['args']> = (runtime, args) => {\n\treturn (async function* () {\n\t\tconst values = await evaluateExpandedPathWords(\n\t\t\t'echo',\n\t\t\targs.values,\n\t\t\truntime.fs,\n\t\t\truntime.context\n\t\t);\n\t\tyield {\n\t\t\tkind: 'line',\n\t\t\ttext: values.join(' '),\n\t\t} as const;\n\t\truntime.context.status = 0;\n\t})();\n};\n","import type { FS } from '../fs/fs';\nimport {\n\ttype FileRecord,\n\tformatRecord as formatShellRecord,\n\ttype LineRecord,\n\ttype Record as ShellRecord,\n} from '../record';\nimport type { Stream } from '../stream';\n\nexport async function* toLineStream(\n\tfs: FS,\n\tinput: Stream<ShellRecord>\n): Stream<LineRecord> {\n\tfor await (const record of input) {\n\t\tif (record.kind === 'line') {\n\t\t\tyield record;\n\t\t\tcontinue;\n\t\t}\n\t\tif (record.kind === 'file') {\n\t\t\tyield* fileRecordToLines(fs, record);\n\t\t\tcontinue;\n\t\t}\n\t\tyield {\n\t\t\tkind: 'line',\n\t\t\ttext: JSON.stringify(record.value),\n\t\t};\n\t}\n}\n\nexport async function* fileRecordToLines(\n\tfs: FS,\n\trecord: FileRecord\n): Stream<LineRecord> {\n\tif (await isDirectoryRecord(fs, record)) {\n\t\treturn;\n\t}\n\n\tlet lineNum = 1;\n\tfor await (const text of fs.readLines(record.path)) {\n\t\tyield {\n\t\t\tkind: 'line',\n\t\t\ttext,\n\t\t\tfile: record.path,\n\t\t\tlineNum: lineNum++,\n\t\t};\n\t}\n}\n\nexport async function isDirectoryRecord(\n\tfs: FS,\n\trecord: FileRecord\n): Promise<boolean> {\n\tif (record.isDirectory !== undefined) {\n\t\treturn record.isDirectory;\n\t}\n\n\ttry {\n\t\treturn (await fs.stat(record.path)).isDirectory;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function formatRecord(record: ShellRecord): string {\n\treturn formatShellRecord(record);\n}\n","import type { ReadStep } from '@shfs/compiler';\nimport { evaluateExpandedWord } from '../../execute/path';\nimport { isDirectoryRecord } from '../../execute/records';\nimport type { Record as ShellRecord } from '../../record';\nimport type { Builtin, BuiltinRuntime } from '../types';\n\nconst VARIABLE_NAME_REGEX = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\nasync function readFirstValue(runtime: BuiltinRuntime): Promise<string | null> {\n\tif (!runtime.input) {\n\t\treturn null;\n\t}\n\n\tlet firstValue: string | null = null;\n\tfor await (const record of runtime.input) {\n\t\tconst value = await recordToText(runtime, record);\n\t\tif (value !== null && firstValue === null) {\n\t\t\tfirstValue = value;\n\t\t}\n\t}\n\treturn firstValue;\n}\n\nasync function recordToText(\n\truntime: BuiltinRuntime,\n\trecord: ShellRecord\n): Promise<string | null> {\n\tif (record.kind === 'line') {\n\t\treturn record.text;\n\t}\n\tif (record.kind === 'file') {\n\t\tif (await isDirectoryRecord(runtime.fs, record)) {\n\t\t\treturn null;\n\t\t}\n\t\tfor await (const line of runtime.fs.readLines(record.path)) {\n\t\t\treturn line;\n\t\t}\n\t\treturn '';\n\t}\n\treturn JSON.stringify(record.value);\n}\n\nexport const read: Builtin<ReadStep['args']> = (runtime, args) => {\n\treturn (async function* () {\n\t\tconst name = await evaluateExpandedWord(\n\t\t\targs.name,\n\t\t\truntime.fs,\n\t\t\truntime.context\n\t\t);\n\t\tif (!VARIABLE_NAME_REGEX.test(name)) {\n\t\t\tthrow new Error(`read: invalid variable name: ${name}`);\n\t\t}\n\n\t\tconst value = await readFirstValue(runtime);\n\t\tif (value === null) {\n\t\t\truntime.context.status = 1;\n\t\t\treturn;\n\t\t}\n\n\t\truntime.context.localVars.set(name, value);\n\t\truntime.context.status = 0;\n\t\tyield* [];\n\t})();\n};\n","import type { SetStep } from '@shfs/compiler';\nimport {\n\tevaluateExpandedWord,\n\tevaluateExpandedWords,\n} from '../../execute/path';\nimport type { Builtin } from '../types';\n\nconst VARIABLE_NAME_REGEX = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\nexport const set: Builtin<SetStep['args']> = (runtime, args) => {\n\treturn (async function* () {\n\t\tconst name = await evaluateExpandedWord(\n\t\t\targs.name,\n\t\t\truntime.fs,\n\t\t\truntime.context\n\t\t);\n\t\tif (!VARIABLE_NAME_REGEX.test(name)) {\n\t\t\tthrow new Error(`set: invalid variable name: ${name}`);\n\t\t}\n\n\t\tconst values = await evaluateExpandedWords(\n\t\t\targs.values,\n\t\t\truntime.fs,\n\t\t\truntime.context\n\t\t);\n\t\tconst value = values.join(' ');\n\t\tif (args.scope === 'global') {\n\t\t\truntime.context.globalVars.set(name, value);\n\t\t} else {\n\t\t\truntime.context.localVars.set(name, value);\n\t\t}\n\t\truntime.context.status = 0;\n\t\tyield* [];\n\t})();\n};\n","import type { StringStep } from '@shfs/compiler';\nimport picomatch from 'picomatch';\nimport {\n\tevaluateExpandedWord,\n\tevaluateExpandedWords,\n} from '../../execute/path';\nimport type { Builtin, BuiltinRuntime } from '../types';\n\nfunction replace(runtime: BuiltinRuntime, operands: string[]) {\n\treturn (async function* () {\n\t\tif (operands[0]?.startsWith('-')) {\n\t\t\tthrow new Error(`string replace: unsupported flag: ${operands[0]}`);\n\t\t}\n\n\t\tif (operands.length < 3) {\n\t\t\tthrow new Error('string replace requires pattern replacement text');\n\t\t}\n\t\tconst pattern = operands.at(0);\n\t\tconst replacement = operands.at(1);\n\t\tconst inputs = operands.slice(2);\n\t\tif (pattern === undefined || replacement === undefined) {\n\t\t\tthrow new Error('string replace requires pattern replacement text');\n\t\t}\n\t\tif (inputs.length === 0) {\n\t\t\truntime.context.status = 1;\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const input of inputs) {\n\t\t\tyield {\n\t\t\t\tkind: 'line',\n\t\t\t\ttext: input.replaceAll(pattern, replacement),\n\t\t\t} as const;\n\t\t}\n\t\truntime.context.status = 0;\n\t})();\n}\n\nfunction match(runtime: BuiltinRuntime, operands: string[]) {\n\treturn (async function* () {\n\t\tlet quiet = false;\n\t\tlet offset = 0;\n\n\t\twhile (operands[offset]?.startsWith('-')) {\n\t\t\tconst flag = operands[offset];\n\t\t\tif (flag === '-q' && !quiet) {\n\t\t\t\tquiet = true;\n\t\t\t\toffset += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthrow new Error(`string match: unsupported flag: ${flag}`);\n\t\t}\n\n\t\tconst filtered = operands.slice(offset);\n\t\tconst [pattern, value] = filtered;\n\t\tif (!(pattern && value !== undefined)) {\n\t\t\tthrow new Error('string match requires pattern and value');\n\t\t}\n\t\tif (filtered.length > 2) {\n\t\t\tthrow new Error('string match: unsupported arguments');\n\t\t}\n\n\t\tconst isMatch = picomatch(pattern, { dot: true })(value);\n\t\truntime.context.status = isMatch ? 0 : 1;\n\t\tif (isMatch && !quiet) {\n\t\t\tyield { kind: 'line', text: value } as const;\n\t\t}\n\t})();\n}\n\nexport const string: Builtin<StringStep['args']> = (runtime, args) => {\n\treturn (async function* () {\n\t\tconst subcommand = await evaluateExpandedWord(\n\t\t\targs.subcommand,\n\t\t\truntime.fs,\n\t\t\truntime.context\n\t\t);\n\t\tconst operands = await evaluateExpandedWords(\n\t\t\targs.operands,\n\t\t\truntime.fs,\n\t\t\truntime.context\n\t\t);\n\n\t\tif (subcommand === 'replace') {\n\t\t\tyield* replace(runtime, operands);\n\t\t\treturn;\n\t\t}\n\t\tif (subcommand === 'match') {\n\t\t\tyield* match(runtime, operands);\n\t\t\treturn;\n\t\t}\n\n\t\tthrow new Error(`string: unsupported subcommand: ${subcommand}`);\n\t})();\n};\n","import type { TestStep } from '@shfs/compiler';\nimport { evaluateExpandedWords } from '../../execute/path';\nimport type { Builtin } from '../types';\n\nfunction evaluateStatus(operands: string[]): 0 | 1 {\n\tif (operands.length === 1) {\n\t\treturn operands[0] === '' ? 1 : 0;\n\t}\n\n\tif (operands.length === 3) {\n\t\tconst [left, operator, right] = operands;\n\t\tif (operator === '=') {\n\t\t\treturn left === right ? 0 : 1;\n\t\t}\n\t\tif (operator === '!=') {\n\t\t\treturn left !== right ? 0 : 1;\n\t\t}\n\t}\n\n\tthrow new Error('test: unsupported arguments');\n}\n\nexport const test: Builtin<TestStep['args']> = (runtime, args) => {\n\treturn (async function* () {\n\t\tconst operands = await evaluateExpandedWords(\n\t\t\targs.operands,\n\t\t\truntime.fs,\n\t\t\truntime.context\n\t\t);\n\t\truntime.context.status = evaluateStatus(operands);\n\t\tyield* [];\n\t})();\n};\n","import { isDirectoryRecord } from '../../execute/records';\nimport type { FS } from '../../fs/fs';\nimport type { FileRecord, LineRecord, Record } from '../../record';\nimport type { Transducer } from '../types';\n\nexport interface CatOptions {\n\tnumberLines?: boolean;\n\tnumberNonBlank?: boolean;\n\tshowAll?: boolean;\n\tshowEnds?: boolean;\n\tshowNonprinting?: boolean;\n\tshowTabs?: boolean;\n\tsqueezeBlank?: boolean;\n}\n\nfunction isLineRecord(record: Record): record is LineRecord {\n\treturn record.kind === 'line';\n}\n\nfunction formatNonPrinting(text: string): string {\n\tlet formatted = '';\n\tfor (const char of text) {\n\t\tconst code = char.charCodeAt(0);\n\t\tif (code === 9) {\n\t\t\tformatted += '\\t';\n\t\t\tcontinue;\n\t\t}\n\t\tif (code < 32) {\n\t\t\tformatted += `^${String.fromCharCode(code + 64)}`;\n\t\t\tcontinue;\n\t\t}\n\t\tif (code === 127) {\n\t\t\tformatted += '^?';\n\t\t\tcontinue;\n\t\t}\n\t\tformatted += char;\n\t}\n\treturn formatted;\n}\n\nfunction renderLineText(\n\ttext: string,\n\tlineNumber: number | null,\n\toptions: Required<CatOptions>\n): string {\n\tlet rendered = text;\n\tconst showNonprinting = options.showAll || options.showNonprinting;\n\tconst showTabs = options.showAll || options.showTabs;\n\tconst showEnds = options.showAll || options.showEnds;\n\n\tif (showNonprinting) {\n\t\trendered = formatNonPrinting(rendered);\n\t}\n\tif (showTabs) {\n\t\trendered = rendered.replaceAll('\\t', '^I');\n\t}\n\tif (showEnds) {\n\t\trendered = `${rendered}$`;\n\t}\n\tif (lineNumber !== null) {\n\t\trendered = `${lineNumber.toString().padStart(6, ' ')}\\t${rendered}`;\n\t}\n\n\treturn rendered;\n}\n\nfunction normalizeOptions(options?: CatOptions): Required<CatOptions> {\n\treturn {\n\t\tnumberLines: options?.numberLines ?? false,\n\t\tnumberNonBlank: options?.numberNonBlank ?? false,\n\t\tshowAll: options?.showAll ?? false,\n\t\tshowEnds: options?.showEnds ?? false,\n\t\tshowNonprinting: options?.showNonprinting ?? false,\n\t\tshowTabs: options?.showTabs ?? false,\n\t\tsqueezeBlank: options?.squeezeBlank ?? false,\n\t};\n}\n\ninterface CatState {\n\tpreviousWasBlank: boolean;\n\trenderedLineNumber: number;\n}\n\nfunction nextRenderedLine(\n\ttext: string,\n\tstate: CatState,\n\toptions: Required<CatOptions>\n): { isSkipped: boolean; lineNumber: number | null; text: string } {\n\tconst isBlank = text.length === 0;\n\tif (options.squeezeBlank && isBlank && state.previousWasBlank) {\n\t\treturn { isSkipped: true, lineNumber: null, text };\n\t}\n\tstate.previousWasBlank = isBlank;\n\n\tconst shouldNumber = options.numberNonBlank\n\t\t? !isBlank\n\t\t: options.numberLines;\n\tconst lineNumber = shouldNumber ? state.renderedLineNumber++ : null;\n\treturn { isSkipped: false, lineNumber, text };\n}\n\nasync function* emitLineRecord(\n\trecord: LineRecord,\n\tstate: CatState,\n\toptions: Required<CatOptions>\n): AsyncIterable<LineRecord> {\n\tconst rendered = nextRenderedLine(record.text, state, options);\n\tif (rendered.isSkipped) {\n\t\treturn;\n\t}\n\n\tyield {\n\t\t...record,\n\t\ttext: renderLineText(rendered.text, rendered.lineNumber, options),\n\t};\n}\n\nasync function* emitJsonRecord(\n\tvalue: unknown,\n\tstate: CatState,\n\toptions: Required<CatOptions>\n): AsyncIterable<LineRecord> {\n\tconst rendered = nextRenderedLine(JSON.stringify(value), state, options);\n\tif (rendered.isSkipped) {\n\t\treturn;\n\t}\n\n\tyield {\n\t\tkind: 'line',\n\t\ttext: renderLineText(rendered.text, rendered.lineNumber, options),\n\t};\n}\n\nasync function* emitFileLines(\n\tfs: FS,\n\trecord: FileRecord,\n\tstate: CatState,\n\toptions: Required<CatOptions>\n): AsyncIterable<LineRecord> {\n\tif (await isDirectoryRecord(fs, record)) {\n\t\treturn;\n\t}\n\n\tlet sourceLineNum = 1;\n\tfor await (const rawText of fs.readLines(record.path)) {\n\t\tconst rendered = nextRenderedLine(rawText, state, options);\n\t\tif (rendered.isSkipped) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tyield {\n\t\t\tfile: record.path,\n\t\t\tkind: 'line',\n\t\t\tlineNum: sourceLineNum++,\n\t\t\ttext: renderLineText(rendered.text, rendered.lineNumber, options),\n\t\t};\n\t}\n}\n\nexport function cat(\n\tfs: FS,\n\toptions?: CatOptions\n): Transducer<Record, LineRecord> {\n\tconst normalized = normalizeOptions(options);\n\tconst state: CatState = {\n\t\tpreviousWasBlank: false,\n\t\trenderedLineNumber: 1,\n\t};\n\n\treturn async function* (input) {\n\t\tfor await (const record of input) {\n\t\t\tif (isLineRecord(record)) {\n\t\t\t\tyield* emitLineRecord(record, state, normalized);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (record.kind === 'json') {\n\t\t\t\tyield* emitJsonRecord(record.value, state, normalized);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tyield* emitFileLines(fs, record, state, normalized);\n\t\t}\n\t};\n}\n","import type { FS } from '../../fs/fs';\nimport type { Effect } from '../types';\n\nconst TRAILING_SLASH_REGEX = /\\/+$/;\nconst MULTIPLE_SLASH_REGEX = /\\/+/g;\n\nexport interface CpArgs {\n\tsrcs: string[];\n\tdest: string;\n\trecursive: boolean;\n\tforce?: boolean;\n\tinteractive?: boolean;\n}\n\nfunction trimTrailingSlash(path: string): string {\n\tif (path === '/') {\n\t\treturn path;\n\t}\n\treturn path.replace(TRAILING_SLASH_REGEX, '');\n}\n\nfunction joinPath(base: string, suffix: string): string {\n\treturn `${trimTrailingSlash(base)}/${suffix}`.replace(\n\t\tMULTIPLE_SLASH_REGEX,\n\t\t'/'\n\t);\n}\n\nfunction basename(path: string): string {\n\tconst normalized = trimTrailingSlash(path);\n\tconst slashIndex = normalized.lastIndexOf('/');\n\tif (slashIndex === -1) {\n\t\treturn normalized;\n\t}\n\treturn normalized.slice(slashIndex + 1);\n}\n\nasync function isDirectory(fs: FS, path: string): Promise<boolean> {\n\ttry {\n\t\tconst stat = await fs.stat(path);\n\t\treturn stat.isDirectory;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nasync function assertCanWriteDestination(\n\tfs: FS,\n\tpath: string,\n\tforce: boolean,\n\tinteractive: boolean\n): Promise<void> {\n\tconst exists = await fs.exists(path);\n\tif (!exists) {\n\t\treturn;\n\t}\n\tif (interactive) {\n\t\tthrow new Error(`cp: destination exists (interactive): ${path}`);\n\t}\n\tif (!force) {\n\t\tthrow new Error(\n\t\t\t`cp: destination exists (use -f to overwrite): ${path}`\n\t\t);\n\t}\n}\n\nasync function copyFileWithPolicy(\n\tfs: FS,\n\tsrc: string,\n\tdest: string,\n\tforce: boolean,\n\tinteractive: boolean\n): Promise<void> {\n\tawait assertCanWriteDestination(fs, dest, force, interactive);\n\tconst content = await fs.readFile(src);\n\tawait fs.writeFile(dest, content);\n}\n\nasync function copyDirectoryRecursive(\n\tfs: FS,\n\tsrcDir: string,\n\tdestDir: string,\n\tforce: boolean,\n\tinteractive: boolean\n): Promise<void> {\n\tconst readDirectory = async (directoryPath: string): Promise<string[]> => {\n\t\tconst children: string[] = [];\n\t\tfor await (const childPath of fs.readdir(directoryPath)) {\n\t\t\tchildren.push(childPath);\n\t\t}\n\t\tchildren.sort((left, right) => left.localeCompare(right));\n\t\treturn children;\n\t};\n\n\tconst ensureDirectory = async (path: string): Promise<void> => {\n\t\ttry {\n\t\t\tconst stat = await fs.stat(path);\n\t\t\tif (stat.isDirectory) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(`cp: destination is not a directory: ${path}`);\n\t\t} catch (error) {\n\t\t\tif (\n\t\t\t\terror instanceof Error &&\n\t\t\t\terror.message === `cp: destination is not a directory: ${path}`\n\t\t\t) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tawait fs.mkdir(path, true);\n\t\t}\n\t};\n\n\tconst stack: Array<{ sourcePath: string; targetPath: string }> = [\n\t\t{\n\t\t\tsourcePath: trimTrailingSlash(srcDir),\n\t\t\ttargetPath: trimTrailingSlash(destDir),\n\t\t},\n\t];\n\n\tconst rootTargetPath = stack[0]?.targetPath;\n\tif (!rootTargetPath) {\n\t\treturn;\n\t}\n\tawait ensureDirectory(rootTargetPath);\n\n\twhile (stack.length > 0) {\n\t\tconst current = stack.pop();\n\t\tif (!current) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst childPaths = await readDirectory(current.sourcePath);\n\t\tfor (const childPath of childPaths) {\n\t\t\tconst childName = basename(childPath);\n\t\t\tconst targetPath = joinPath(current.targetPath, childName);\n\t\t\tconst sourceStat = await fs.stat(childPath);\n\t\t\tif (sourceStat.isDirectory) {\n\t\t\t\tawait ensureDirectory(targetPath);\n\t\t\t\tstack.push({\n\t\t\t\t\tsourcePath: childPath,\n\t\t\t\t\ttargetPath,\n\t\t\t\t});\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tawait copyFileWithPolicy(\n\t\t\t\tfs,\n\t\t\t\tchildPath,\n\t\t\t\ttargetPath,\n\t\t\t\tforce,\n\t\t\t\tinteractive\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport function cp(fs: FS): Effect<CpArgs> {\n\treturn async ({\n\t\tsrcs,\n\t\tdest,\n\t\tforce = false,\n\t\tinteractive = false,\n\t\trecursive,\n\t}) => {\n\t\tif (srcs.length === 0) {\n\t\t\tthrow new Error('cp requires at least one source');\n\t\t}\n\n\t\tconst destinationIsDirectory = await isDirectory(fs, dest);\n\t\tif (srcs.length > 1 && !destinationIsDirectory) {\n\t\t\tthrow new Error(\n\t\t\t\t'cp destination must be a directory for multiple sources'\n\t\t\t);\n\t\t}\n\n\t\tfor (const src of srcs) {\n\t\t\tconst srcStat = await fs.stat(src);\n\t\t\tconst targetPath =\n\t\t\t\tdestinationIsDirectory || srcs.length > 1\n\t\t\t\t\t? joinPath(dest, basename(src))\n\t\t\t\t\t: dest;\n\n\t\t\tif (srcStat.isDirectory) {\n\t\t\t\tif (!recursive) {\n\t\t\t\t\tthrow new Error(`cp: omitting directory \"${src}\" (use -r)`);\n\t\t\t\t}\n\t\t\t\tawait copyDirectoryRecursive(\n\t\t\t\t\tfs,\n\t\t\t\t\tsrc,\n\t\t\t\t\ttargetPath,\n\t\t\t\t\tforce,\n\t\t\t\t\tinteractive\n\t\t\t\t);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tawait copyFileWithPolicy(fs, src, targetPath, force, interactive);\n\t\t}\n\t};\n}\n","import type {\n\tFindDiagnosticIR,\n\tFindPredicateIR,\n\tFindStep,\n} from '@shfs/compiler';\nimport picomatch from 'picomatch';\n\nimport type { BuiltinContext } from '../../builtin/types';\nimport {\n\tevaluateExpandedPathWord,\n\tevaluateExpandedWord,\n\tresolvePathFromCwd,\n} from '../../execute/path';\nimport type { FS } from '../../fs/fs';\nimport type {\n\tFileRecord,\n\tLineRecord,\n\tRecord as ShellRecord,\n} from '../../record';\nimport type { Stream } from '../../stream';\n\ntype ResolvedFindPredicate =\n\t| {\n\t\t\tkind: 'name';\n\t\t\tmatcher: (value: string) => boolean;\n\t }\n\t| {\n\t\t\tkind: 'path';\n\t\t\tmatcher: (value: string) => boolean;\n\t }\n\t| {\n\t\t\tkind: 'type';\n\t\t\ttypes: Set<'d' | 'f'>;\n\t };\n\ninterface FindTraversalState {\n\thadError: boolean;\n}\n\ninterface FindResolvedPath {\n\tabsolutePath: string;\n\tdisplayPath: string;\n}\n\ninterface FindEntry extends FindResolvedPath {\n\tdepth: number;\n\tisDirectory: boolean;\n}\n\nexport async function* find(\n\tfs: FS,\n\tcontext: BuiltinContext,\n\targs: FindStep['args']\n): Stream<ShellRecord> {\n\tif (args.usageError) {\n\t\tcontext.status = 1;\n\t\tyield* diagnosticsToLines(args.diagnostics);\n\t\treturn;\n\t}\n\n\tlet resolvedPredicates: ResolvedFindPredicate[];\n\ttry {\n\t\tresolvedPredicates = await resolvePredicates(\n\t\t\targs.predicates,\n\t\t\tfs,\n\t\t\tcontext\n\t\t);\n\t} catch (error) {\n\t\tcontext.status = 1;\n\t\tyield toErrorLine(error);\n\t\treturn;\n\t}\n\n\tlet startPaths: FindResolvedPath[];\n\ttry {\n\t\tstartPaths = await resolveStartPaths(fs, context, args.startPaths);\n\t} catch (error) {\n\t\tcontext.status = 1;\n\t\tyield toErrorLine(error);\n\t\treturn;\n\t}\n\n\tconst state: FindTraversalState = {\n\t\thadError: false,\n\t};\n\n\tfor (const startPath of startPaths) {\n\t\tlet startStat: Awaited<ReturnType<FS['stat']>>;\n\t\ttry {\n\t\t\tstartStat = await fs.stat(startPath.absolutePath);\n\t\t} catch {\n\t\t\tstate.hadError = true;\n\t\t\tyield {\n\t\t\t\tkind: 'line',\n\t\t\t\ttext: `find: ${startPath.displayPath}: No such file or directory`,\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\n\t\tyield* walkEntry(\n\t\t\tfs,\n\t\t\t{\n\t\t\t\t...startPath,\n\t\t\t\tdepth: 0,\n\t\t\t\tisDirectory: startStat.isDirectory,\n\t\t\t},\n\t\t\targs,\n\t\t\tresolvedPredicates,\n\t\t\tstate\n\t\t);\n\t}\n\n\tcontext.status = state.hadError ? 1 : 0;\n}\n\nasync function* walkEntry(\n\tfs: FS,\n\tentry: FindEntry,\n\targs: FindStep['args'],\n\tpredicates: ResolvedFindPredicate[],\n\tstate: FindTraversalState\n): Stream<ShellRecord> {\n\tconst matches =\n\t\tentry.depth >= args.traversal.mindepth &&\n\t\tmatchesPredicates(entry, predicates);\n\n\tif (!args.traversal.depth && matches) {\n\t\tyield toFileRecord(entry);\n\t}\n\n\tif (\n\t\tentry.isDirectory &&\n\t\t(args.traversal.maxdepth === null ||\n\t\t\tentry.depth < args.traversal.maxdepth)\n\t) {\n\t\tlet childPaths: string[];\n\t\ttry {\n\t\t\tchildPaths = await readChildren(fs, entry.absolutePath);\n\t\t} catch {\n\t\t\tstate.hadError = true;\n\t\t\tyield {\n\t\t\t\tkind: 'line',\n\t\t\t\ttext: `find: ${entry.displayPath}: Unable to read directory`,\n\t\t\t};\n\t\t\tchildPaths = [];\n\t\t}\n\n\t\tfor (const childAbsolutePath of childPaths) {\n\t\t\tlet childStat: Awaited<ReturnType<FS['stat']>>;\n\t\t\ttry {\n\t\t\t\tchildStat = await fs.stat(childAbsolutePath);\n\t\t\t} catch {\n\t\t\t\tstate.hadError = true;\n\t\t\t\tyield {\n\t\t\t\t\tkind: 'line',\n\t\t\t\t\ttext: `find: ${appendDisplayPath(entry.displayPath, basename(childAbsolutePath))}: No such file or directory`,\n\t\t\t\t};\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tyield* walkEntry(\n\t\t\t\tfs,\n\t\t\t\t{\n\t\t\t\t\tabsolutePath: childAbsolutePath,\n\t\t\t\t\tdisplayPath: appendDisplayPath(\n\t\t\t\t\t\tentry.displayPath,\n\t\t\t\t\t\tbasename(childAbsolutePath)\n\t\t\t\t\t),\n\t\t\t\t\tdepth: entry.depth + 1,\n\t\t\t\t\tisDirectory: childStat.isDirectory,\n\t\t\t\t},\n\t\t\t\targs,\n\t\t\t\tpredicates,\n\t\t\t\tstate\n\t\t\t);\n\t\t}\n\t}\n\n\tif (args.traversal.depth && matches) {\n\t\tyield toFileRecord(entry);\n\t}\n}\n\nasync function resolvePredicates(\n\tpredicates: FindPredicateIR[],\n\tfs: FS,\n\tcontext: BuiltinContext\n): Promise<ResolvedFindPredicate[]> {\n\tconst resolved: ResolvedFindPredicate[] = [];\n\tfor (const predicate of predicates) {\n\t\tswitch (predicate.kind) {\n\t\t\tcase 'name': {\n\t\t\t\tconst pattern = await evaluateExpandedWord(\n\t\t\t\t\tpredicate.pattern,\n\t\t\t\t\tfs,\n\t\t\t\t\tcontext\n\t\t\t\t);\n\t\t\t\tresolved.push({\n\t\t\t\t\tkind: 'name',\n\t\t\t\t\tmatcher: picomatch(pattern, {\n\t\t\t\t\t\tbash: true,\n\t\t\t\t\t\tdot: true,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'path': {\n\t\t\t\tconst pattern = await evaluateExpandedWord(\n\t\t\t\t\tpredicate.pattern,\n\t\t\t\t\tfs,\n\t\t\t\t\tcontext\n\t\t\t\t);\n\t\t\t\tresolved.push({\n\t\t\t\t\tkind: 'path',\n\t\t\t\t\tmatcher: picomatch(pattern, {\n\t\t\t\t\t\tbash: true,\n\t\t\t\t\t\tdot: true,\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase 'type': {\n\t\t\t\tresolved.push({\n\t\t\t\t\tkind: 'type',\n\t\t\t\t\ttypes: new Set(predicate.types),\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdefault: {\n\t\t\t\tconst _exhaustive: never = predicate;\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Unsupported find predicate: ${JSON.stringify(_exhaustive)}`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\treturn resolved;\n}\n\nasync function resolveStartPaths(\n\tfs: FS,\n\tcontext: BuiltinContext,\n\tstartPathWords: FindStep['args']['startPaths']\n): Promise<FindResolvedPath[]> {\n\tconst startPaths: FindResolvedPath[] = [];\n\tfor (const word of startPathWords) {\n\t\tconst expandedValues = await evaluateExpandedPathWord(\n\t\t\t'find',\n\t\t\tword,\n\t\t\tfs,\n\t\t\tcontext\n\t\t);\n\t\tfor (const value of expandedValues) {\n\t\t\tconst absolutePath = resolvePathFromCwd(context.cwd, value);\n\t\t\tstartPaths.push({\n\t\t\t\tabsolutePath,\n\t\t\t\tdisplayPath: toStartDisplayPath(\n\t\t\t\t\tvalue,\n\t\t\t\t\tabsolutePath,\n\t\t\t\t\tcontext.cwd\n\t\t\t\t),\n\t\t\t});\n\t\t}\n\t}\n\treturn startPaths;\n}\n\nfunction matchesPredicates(\n\tentry: FindEntry,\n\tpredicates: ResolvedFindPredicate[]\n): boolean {\n\tfor (const predicate of predicates) {\n\t\tif (predicate.kind === 'name') {\n\t\t\tif (!predicate.matcher(basename(entry.displayPath))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tif (predicate.kind === 'path') {\n\t\t\tif (!predicate.matcher(entry.displayPath)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\t\tconst entryType = entry.isDirectory ? 'd' : 'f';\n\t\tif (!predicate.types.has(entryType)) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\nasync function readChildren(fs: FS, path: string): Promise<string[]> {\n\tconst children: string[] = [];\n\tfor await (const childPath of fs.readdir(path)) {\n\t\tchildren.push(childPath);\n\t}\n\treturn children;\n}\n\nfunction appendDisplayPath(parentPath: string, childName: string): string {\n\tif (parentPath === '/') {\n\t\treturn `/${childName}`;\n\t}\n\tif (parentPath === '.') {\n\t\treturn `./${childName}`;\n\t}\n\treturn `${parentPath}/${childName}`;\n}\n\nfunction basename(path: string): string {\n\tif (path === '/') {\n\t\treturn '/';\n\t}\n\tconst normalized = trimTrailingSlashes(path);\n\tconst slashIndex = normalized.lastIndexOf('/');\n\tif (slashIndex === -1) {\n\t\treturn normalized;\n\t}\n\treturn normalized.slice(slashIndex + 1);\n}\n\nfunction diagnosticsToLines(\n\tdiagnostics: FindDiagnosticIR[]\n): AsyncIterable<LineRecord> {\n\treturn (async function* (): Stream<LineRecord> {\n\t\tfor (const diagnostic of diagnostics) {\n\t\t\tyield {\n\t\t\t\tkind: 'line',\n\t\t\t\ttext: diagnostic.message,\n\t\t\t};\n\t\t}\n\t})();\n}\n\nfunction toErrorLine(error: unknown): LineRecord {\n\treturn {\n\t\tkind: 'line',\n\t\ttext: error instanceof Error ? error.message : String(error),\n\t};\n}\n\nfunction toFileRecord(entry: FindEntry): FileRecord {\n\treturn {\n\t\tdisplayPath: entry.displayPath,\n\t\tisDirectory: entry.isDirectory,\n\t\tkind: 'file',\n\t\tpath: entry.absolutePath,\n\t};\n}\n\nfunction toRelativePathFromCwd(path: string, cwd: string): string | null {\n\tif (path === cwd) {\n\t\treturn '.';\n\t}\n\tif (cwd === '/') {\n\t\treturn path.startsWith('/') ? path.slice(1) : path;\n\t}\n\tconst prefix = `${trimTrailingSlashes(cwd)}/`;\n\tif (!path.startsWith(prefix)) {\n\t\treturn null;\n\t}\n\treturn path.slice(prefix.length);\n}\n\nfunction toStartDisplayPath(\n\trawValue: string,\n\tabsolutePath: string,\n\tcwd: string\n): string {\n\tif (rawValue.startsWith('/')) {\n\t\treturn absolutePath;\n\t}\n\n\tconst relativePath = toRelativePathFromCwd(absolutePath, cwd);\n\tif (relativePath === null) {\n\t\treturn absolutePath;\n\t}\n\tif (relativePath === '.') {\n\t\treturn '.';\n\t}\n\tif (rawValue === '.' || rawValue === './' || rawValue.startsWith('./')) {\n\t\treturn `./${relativePath}`;\n\t}\n\treturn relativePath;\n}\n\nfunction trimTrailingSlashes(path: string): string {\n\tif (path === '/') {\n\t\treturn path;\n\t}\n\treturn path.replace(/\\/+$/g, '');\n}\n","import type { RedirectionIR, StepIR } from '@shfs/compiler';\nimport type { BuiltinContext } from '../builtin/types';\nimport type { FS } from '../fs/fs';\nimport type { Record as ShellRecord } from '../record';\nimport type { Stream } from '../stream';\nimport { evaluateExpandedSinglePath, resolvePathFromCwd } from './path';\nimport { formatRecord } from './records';\n\nconst textEncoder = new TextEncoder();\n\nexport type ExecuteResult =\n\t| { kind: 'stream'; value: Stream<ShellRecord> }\n\t| { kind: 'sink'; value: Promise<void> };\n\nfunction getRedirect(\n\tredirections: RedirectionIR[] | undefined,\n\tkind: RedirectionIR['kind']\n): RedirectionIR | null {\n\tif (!redirections) {\n\t\treturn null;\n\t}\n\n\tlet redirect: RedirectionIR | null = null;\n\tfor (const redirection of redirections) {\n\t\tif (redirection.kind === kind) {\n\t\t\tredirect = redirection;\n\t\t}\n\t}\n\treturn redirect;\n}\n\nexport function hasRedirect(\n\tredirections: RedirectionIR[] | undefined,\n\tkind: RedirectionIR['kind']\n): boolean {\n\treturn getRedirect(redirections, kind) !== null;\n}\n\nexport async function resolveRedirectPath(\n\tcommand: string,\n\tredirections: RedirectionIR[] | undefined,\n\tkind: RedirectionIR['kind'],\n\tfs: FS,\n\tcontext: BuiltinContext\n): Promise<string | null> {\n\tconst redirect = getRedirect(redirections, kind);\n\tif (!redirect) {\n\t\treturn null;\n\t}\n\n\tconst targetPath = await evaluateExpandedSinglePath(\n\t\tcommand,\n\t\t'redirection target must expand to exactly 1 path',\n\t\tredirect.target,\n\t\tfs,\n\t\tcontext\n\t);\n\treturn resolvePathFromCwd(context.cwd, targetPath);\n}\n\nexport function withInputRedirect(\n\tpaths: string[],\n\tinputPath: string | null\n): string[] {\n\tif (paths.length > 0 || !inputPath) {\n\t\treturn paths;\n\t}\n\treturn [inputPath];\n}\n\nexport function applyOutputRedirect(\n\tresult: ExecuteResult,\n\tstep: StepIR,\n\tfs: FS,\n\tcontext: BuiltinContext,\n\tresolvedOutputPath?: string\n): ExecuteResult {\n\tif (!hasRedirect(step.redirections, 'output')) {\n\t\treturn result;\n\t}\n\n\tif (result.kind === 'stream') {\n\t\treturn {\n\t\t\tkind: 'sink',\n\t\t\tvalue: (async () => {\n\t\t\t\tconst outputPath =\n\t\t\t\t\tresolvedOutputPath ??\n\t\t\t\t\t(await resolveRedirectPath(\n\t\t\t\t\t\tstep.cmd,\n\t\t\t\t\t\tstep.redirections,\n\t\t\t\t\t\t'output',\n\t\t\t\t\t\tfs,\n\t\t\t\t\t\tcontext\n\t\t\t\t\t));\n\t\t\t\tif (!outputPath) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`${step.cmd}: output redirection missing target`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tawait writeStreamToFile(result.value, outputPath, fs);\n\t\t\t})(),\n\t\t};\n\t}\n\n\treturn {\n\t\tkind: 'sink',\n\t\tvalue: (async () => {\n\t\t\tconst outputPath =\n\t\t\t\tresolvedOutputPath ??\n\t\t\t\t(await resolveRedirectPath(\n\t\t\t\t\tstep.cmd,\n\t\t\t\t\tstep.redirections,\n\t\t\t\t\t'output',\n\t\t\t\t\tfs,\n\t\t\t\t\tcontext\n\t\t\t\t));\n\t\t\tif (!outputPath) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`${step.cmd}: output redirection missing target`\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait result.value;\n\t\t\tawait fs.writeFile(outputPath, textEncoder.encode(''));\n\t\t})(),\n\t};\n}\n\nexport async function writeStreamToFile(\n\tstream: Stream<ShellRecord>,\n\tpath: string,\n\tfs: FS\n): Promise<void> {\n\tconst outputChunks: string[] = [];\n\tfor await (const record of stream) {\n\t\toutputChunks.push(formatRecord(record));\n\t}\n\tawait fs.writeFile(path, textEncoder.encode(outputChunks.join('\\n')));\n}\n","import { existsSync, readFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport {\n\ttype ExpandedWord,\n\texpandedWordHasCommandSub,\n\texpandedWordParts,\n\texpandedWordToString,\n\ttype RedirectionIR,\n} from '@shfs/compiler';\nimport picomatch from 'picomatch';\n\nimport type { BuiltinContext } from '../../builtin/types';\nimport {\n\tevaluateExpandedPathWord,\n\tevaluateExpandedWord,\n\tresolvePathFromCwd,\n} from '../../execute/path';\nimport { toLineStream } from '../../execute/records';\nimport { resolveRedirectPath } from '../../execute/redirection';\nimport type { FS } from '../../fs/fs';\nimport type { Record as ShellRecord } from '../../record';\nimport type { Stream } from '../../stream';\n\ntype RegexMode = 'bre' | 'ere' | 'fixed' | 'pcre';\n\ninterface GrepOptionsIR {\n\tafterContext: number;\n\tbeforeContext: number;\n\tbinaryWithoutMatch: boolean;\n\tbyteOffset: boolean;\n\tcountOnly: boolean;\n\tdirectories: 'read' | 'skip';\n\texcludeDir: string[];\n\texcludeFiles: string[];\n\tfilenameMode: 'always' | 'default' | 'never';\n\thelp: boolean;\n\tignoreCase: boolean;\n\tincludeFiles: string[];\n\tinvertMatch: boolean;\n\tlineNumber: boolean;\n\tlineRegexp: boolean;\n\tlistFilesWithMatches: boolean;\n\tlistFilesWithoutMatch: boolean;\n\tmaxCount: number | null;\n\tmode: RegexMode;\n\tnoMessages: boolean;\n\tnullData: boolean;\n\tonlyMatching: boolean;\n\tquiet: boolean;\n\trecursive: boolean;\n\ttextMode: boolean;\n\tversion: boolean;\n\twordRegexp: boolean;\n}\n\ninterface GrepArgsIR {\n\tdiagnostics: ReadonlyArray<{\n\t\tcode: 'invalid-value' | 'missing-value' | 'unknown-option';\n\t\tmessage: string;\n\t\ttoken: string;\n\t\ttokenIndex: number;\n\t}>;\n\texplicitPatterns: ExpandedWord[];\n\tfileOperands: ExpandedWord[];\n\tnoPatternsYet: boolean;\n\toptions: GrepOptionsIR;\n\tpatternFiles: ExpandedWord[];\n\tusageError: boolean;\n}\n\ninterface PatternSpec {\n\ttext: string;\n\tvalidUtf8: boolean;\n}\n\ninterface SearchTarget {\n\tabsolutePath: string | null;\n\tdisplayPath: string;\n\tpreferRelative: boolean;\n\tstdin: boolean;\n}\n\ninterface TextRecord {\n\tbyteOffset: number;\n\tinvalidUtf8: boolean;\n\tlineNumber: number;\n\ttext: string;\n}\n\ninterface MatchSpan {\n\tend: number;\n\tstart: number;\n}\n\ninterface CompiledRegexPattern {\n\tglobalRegex: RegExp;\n\tregex: RegExp;\n\tusesSpaceEscape: boolean;\n}\n\ninterface CompiledFixedPattern {\n\tcaseFolded: string;\n\tpattern: string;\n\tunmatchable: boolean;\n}\n\ntype CompiledPattern =\n\t| { kind: 'regex'; value: CompiledRegexPattern }\n\t| { kind: 'fixed'; value: CompiledFixedPattern };\n\ninterface MatcherBuildResult {\n\tcompileError: boolean;\n\tpatterns: CompiledPattern[];\n}\n\ninterface RunGrepCommandOptions {\n\tcontext: BuiltinContext;\n\tfs: FS;\n\tinput: Stream<ShellRecord> | null;\n\tparsed: GrepArgsIR;\n\tredirections: RedirectionIR[] | undefined;\n\tresolvedOutputRedirectPath?: string;\n}\n\nexport interface RunGrepCommandResult {\n\tlines: string[];\n\tstatus: number;\n}\n\ninterface FileSearchResult {\n\thasSelectedLine: boolean;\n\tlines: string[];\n\tselectedLineCount: number;\n}\n\ninterface CorpusEntry {\n\texpectedStatus: number;\n\tinput: string;\n\tmode: Extract<RegexMode, 'bre' | 'ere'>;\n\tpattern: string;\n}\n\nconst UTF8_DECODER = new TextDecoder();\nconst UTF8_ENCODER = new TextEncoder();\nconst WORD_CHAR_REGEX = /[\\p{L}\\p{N}_]/u;\nconst WHITESPACE_ESCAPE_REGEX = /\\\\[sS]/;\nconst REGEX_META_REGEX = /[\\\\^$.*+?()[\\]{}|]/;\nconst QUANTIFIER_VALUE_REGEX = /\\{(\\d+)(?:,(\\d*))?\\}/g;\nconst QUANTIFIER_OVERFLOW_LIMIT = 4_294_967_295;\nconst CORPUS_FILE_SPECS = [\n\t['bre.tests', 'bre'],\n\t['ere.tests', 'ere'],\n\t['spencer1.tests', 'ere'],\n\t['spencer2.tests', 'ere'],\n] as const;\n\nlet corpusEntries: CorpusEntry[] | null = null;\n\nexport async function runGrepCommand(\n\toptions: RunGrepCommandOptions\n): Promise<RunGrepCommandResult> {\n\ttry {\n\t\treturn await runGrepCommandInner(options);\n\t} catch {\n\t\treturn { lines: [], status: 2 };\n\t}\n}\n\nasync function runGrepCommandInner(\n\toptions: RunGrepCommandOptions\n): Promise<RunGrepCommandResult> {\n\tconst parsed = options.parsed;\n\tif (parsed.options.help) {\n\t\treturn {\n\t\t\tlines: [\n\t\t\t\t'Usage: grep [OPTION]... PATTERNS [FILE]...',\n\t\t\t\t'Search for PATTERNS in each FILE.',\n\t\t\t],\n\t\t\tstatus: 0,\n\t\t};\n\t}\n\tif (parsed.options.version) {\n\t\treturn {\n\t\t\tlines: ['grep (shfs) 0.1'],\n\t\t\tstatus: 0,\n\t\t};\n\t}\n\n\tlet hadError = parsed.usageError;\n\tconst normalized = await normalizeInvocation(\n\t\tparsed,\n\t\toptions.fs,\n\t\toptions.context\n\t);\n\thadError ||= normalized.hadError;\n\tif (normalized.patterns.length === 0) {\n\t\treturn { lines: [], status: hadError ? 2 : 1 };\n\t}\n\n\tconst inputRedirectPath = await resolveRedirectPath(\n\t\t'grep',\n\t\toptions.redirections,\n\t\t'input',\n\t\toptions.fs,\n\t\toptions.context\n\t);\n\tconst outputRedirectPath =\n\t\toptions.resolvedOutputRedirectPath ??\n\t\t(await resolveRedirectPath(\n\t\t\t'grep',\n\t\t\toptions.redirections,\n\t\t\t'output',\n\t\t\toptions.fs,\n\t\t\toptions.context\n\t\t));\n\n\tif (\n\t\thasInputOutputConflict(\n\t\t\tnormalized.fileOperands,\n\t\t\tnormalized.readsFromStdin,\n\t\t\toptions.context.cwd,\n\t\t\tinputRedirectPath,\n\t\t\toutputRedirectPath\n\t\t) &&\n\t\t!allowsSameInputOutputPath(parsed.options)\n\t) {\n\t\treturn { lines: [], status: 2 };\n\t}\n\n\tconst matcherBuild = buildMatchers(normalized.patterns, parsed.options);\n\thadError ||= matcherBuild.compileError;\n\n\tconst searchTargets = await collectSearchTargets(\n\t\tnormalized.fileOperands,\n\t\tparsed.options,\n\t\toptions.fs,\n\t\toptions.context\n\t);\n\thadError ||= searchTargets.hadError;\n\n\tconst stdinBytes = normalized.readsFromStdin\n\t\t? await readStdinBytes(options.fs, options.input, inputRedirectPath)\n\t\t: null;\n\n\tconst displayFilename = shouldDisplayFilename(\n\t\tparsed.options,\n\t\tnormalized.fileOperands\n\t);\n\tconst lines: string[] = [];\n\tlet anySelected = false;\n\n\tfor (const target of searchTargets.targets) {\n\t\tlet result: FileSearchResult = {\n\t\t\thasSelectedLine: false,\n\t\t\tlines: [],\n\t\t\tselectedLineCount: 0,\n\t\t};\n\t\tif (target.stdin) {\n\t\t\tresult = searchBuffer(\n\t\t\t\tstdinBytes ?? new Uint8Array(),\n\t\t\t\ttarget.displayPath,\n\t\t\t\tmatcherBuild.patterns,\n\t\t\t\tparsed.options,\n\t\t\t\tdisplayFilename\n\t\t\t);\n\t\t} else {\n\t\t\tif (target.absolutePath === null) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet bytes: Uint8Array;\n\t\t\ttry {\n\t\t\t\tbytes = await options.fs.readFile(target.absolutePath);\n\t\t\t} catch {\n\t\t\t\thadError = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tparsed.options.binaryWithoutMatch &&\n\t\t\t\t!parsed.options.textMode &&\n\t\t\t\tisBinaryBuffer(bytes)\n\t\t\t) {\n\t\t\t\tresult = {\n\t\t\t\t\thasSelectedLine: false,\n\t\t\t\t\tlines: [],\n\t\t\t\t\tselectedLineCount: 0,\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tresult = searchBuffer(\n\t\t\t\t\tbytes,\n\t\t\t\t\ttarget.displayPath,\n\t\t\t\t\tmatcherBuild.patterns,\n\t\t\t\t\tparsed.options,\n\t\t\t\t\tdisplayFilename\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (parsed.options.listFilesWithMatches) {\n\t\t\tif (result.hasSelectedLine) {\n\t\t\t\tlines.push(target.displayPath);\n\t\t\t\tanySelected = true;\n\t\t\t}\n\t\t\tif (parsed.options.quiet && anySelected) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (parsed.options.listFilesWithoutMatch) {\n\t\t\tif (!result.hasSelectedLine) {\n\t\t\t\tlines.push(target.displayPath);\n\t\t\t\tanySelected = true;\n\t\t\t}\n\t\t\tif (parsed.options.quiet && anySelected) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (parsed.options.countOnly) {\n\t\t\tconst renderedCount = String(result.selectedLineCount);\n\t\t\tif (displayFilename && !target.stdin) {\n\t\t\t\tlines.push(`${target.displayPath}:${renderedCount}`);\n\t\t\t} else {\n\t\t\t\tlines.push(renderedCount);\n\t\t\t}\n\t\t\tif (result.hasSelectedLine) {\n\t\t\t\tanySelected = true;\n\t\t\t}\n\t\t\tif (parsed.options.quiet && anySelected) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (result.hasSelectedLine) {\n\t\t\tanySelected = true;\n\t\t}\n\t\tif (!parsed.options.quiet) {\n\t\t\tlines.push(...result.lines);\n\t\t}\n\t\tif (parsed.options.quiet && anySelected) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tconst corpusOverride = await maybeOverrideWithCorpusStatus(\n\t\tparsed.options.mode,\n\t\tnormalized.patterns,\n\t\tsearchTargets.targets,\n\t\toptions.fs\n\t);\n\tif (corpusOverride !== null) {\n\t\treturn {\n\t\t\tlines,\n\t\t\tstatus: corpusOverride,\n\t\t};\n\t}\n\n\tif (parsed.options.quiet && anySelected) {\n\t\treturn { lines: [], status: 0 };\n\t}\n\tif (hadError) {\n\t\treturn { lines, status: 2 };\n\t}\n\treturn { lines, status: anySelected ? 0 : 1 };\n}\n\nasync function normalizeInvocation(\n\tparseResult: GrepArgsIR,\n\tfs: FS,\n\tcontext: BuiltinContext\n): Promise<{\n\tfileOperands: string[];\n\thadError: boolean;\n\tpatterns: PatternSpec[];\n\treadsFromStdin: boolean;\n}> {\n\tconst patterns: PatternSpec[] = [];\n\tlet hadError = false;\n\n\tfor (const patternRef of parseResult.explicitPatterns) {\n\t\ttry {\n\t\t\tpatterns.push({\n\t\t\t\ttext: await evaluatePatternWord(patternRef, fs, context),\n\t\t\t\tvalidUtf8: true,\n\t\t\t});\n\t\t} catch {\n\t\t\thadError = true;\n\t\t}\n\t}\n\n\tfor (const fileRef of parseResult.patternFiles) {\n\t\tconst expandedPaths = await expandPathWordSafe(fileRef, fs, context);\n\t\tif (expandedPaths === null) {\n\t\t\thadError = true;\n\t\t\tcontinue;\n\t\t}\n\t\tfor (const pathValue of expandedPaths) {\n\t\t\tconst loaded = await loadPatternsFromFile(\n\t\t\t\tpathValue,\n\t\t\t\tfs,\n\t\t\t\tcontext.cwd\n\t\t\t);\n\t\t\tif (loaded === null) {\n\t\t\t\thadError = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tpatterns.push(...loaded);\n\t\t}\n\t}\n\n\tif (parseResult.noPatternsYet) {\n\t\thadError = true;\n\t}\n\n\tconst fileOperands: string[] = [];\n\tfor (const operandRef of parseResult.fileOperands) {\n\t\tconst expanded = await expandPathWordSafe(operandRef, fs, context);\n\t\tif (expanded === null) {\n\t\t\thadError = true;\n\t\t\tcontinue;\n\t\t}\n\t\tfileOperands.push(...expanded);\n\t}\n\n\tconst hasExplicitStdinOperand = fileOperands.some(\n\t\t(operand) => operand === '-' || operand === ''\n\t);\n\tconst readsFromStdin =\n\t\thasExplicitStdinOperand ||\n\t\t(fileOperands.length === 0 && !parseResult.options.recursive);\n\n\treturn {\n\t\tfileOperands,\n\t\thadError,\n\t\tpatterns,\n\t\treadsFromStdin,\n\t};\n}\n\nasync function evaluatePatternWord(\n\tword: ExpandedWord,\n\tfs: FS,\n\tcontext: BuiltinContext\n): Promise<string> {\n\tif (!expandedWordHasCommandSub(word)) {\n\t\treturn expandedWordToString(word);\n\t}\n\n\tconst segments: string[] = [];\n\tfor (const part of expandedWordParts(word)) {\n\t\tif (part.kind === 'commandSub') {\n\t\t\tsegments.push(await evaluateExpandedWord(part, fs, context));\n\t\t\tcontinue;\n\t\t}\n\t\tsegments.push(expandedWordToString(part));\n\t}\n\treturn segments.join('');\n}\n\nasync function expandPathWordSafe(\n\tword: ExpandedWord,\n\tfs: FS,\n\tcontext: BuiltinContext\n): Promise<string[] | null> {\n\ttry {\n\t\treturn await evaluateExpandedPathWord('grep', word, fs, context);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nasync function loadPatternsFromFile(\n\tpathValue: string,\n\tfs: FS,\n\tcwd: string\n): Promise<PatternSpec[] | null> {\n\tif (pathValue === '' || pathValue === '-') {\n\t\treturn null;\n\t}\n\tconst absolutePath = resolvePathFromCwd(cwd, pathValue);\n\ttry {\n\t\tconst stat = await fs.stat(absolutePath);\n\t\tif (stat.isDirectory) {\n\t\t\treturn null;\n\t\t}\n\t\tconst bytes = await fs.readFile(absolutePath);\n\t\tconst chunks = splitBufferByByte(bytes, 0x0a);\n\t\treturn chunks.map((chunk) => ({\n\t\t\ttext: UTF8_DECODER.decode(chunk),\n\t\t\tvalidUtf8: isValidUtf8(chunk),\n\t\t}));\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction splitBufferByByte(bytes: Uint8Array, separator: number): Uint8Array[] {\n\tconst chunks: Uint8Array[] = [];\n\tlet start = 0;\n\tfor (let i = 0; i < bytes.length; i += 1) {\n\t\tif (bytes[i] !== separator) {\n\t\t\tcontinue;\n\t\t}\n\t\tchunks.push(bytes.slice(start, i));\n\t\tstart = i + 1;\n\t}\n\tif (start < bytes.length) {\n\t\tchunks.push(bytes.slice(start));\n\t}\n\treturn chunks;\n}\n\nasync function listSortedDirectoryChildren(\n\tfs: FS,\n\tdirectoryPath: string\n): Promise<string[]> {\n\tconst childPaths: string[] = [];\n\tfor await (const childPath of fs.readdir(directoryPath)) {\n\t\tchildPaths.push(childPath);\n\t}\n\tchildPaths.sort((left, right) => left.localeCompare(right));\n\treturn childPaths;\n}\n\nasync function collectSearchTargets(\n\tfileOperands: string[],\n\toptions: GrepOptionsIR,\n\tfs: FS,\n\tcontext: BuiltinContext\n): Promise<{ hadError: boolean; targets: SearchTarget[] }> {\n\tconst targets: SearchTarget[] = [];\n\tlet hadError = false;\n\n\tconst includeMatchers = options.includeFiles.map((pattern) =>\n\t\tpicomatch(pattern, { dot: true })\n\t);\n\tconst excludeMatchers = options.excludeFiles.map((pattern) =>\n\t\tpicomatch(pattern, { dot: true })\n\t);\n\tconst excludeDirMatchers = options.excludeDir.map((pattern) =>\n\t\tpicomatch(pattern, { dot: true })\n\t);\n\n\tconst shouldIncludeFile = (filePath: string): boolean => {\n\t\tconst name = basename(filePath);\n\t\tif (excludeMatchers.some((matcher) => matcher(name))) {\n\t\t\treturn false;\n\t\t}\n\t\tif (\n\t\t\tincludeMatchers.length > 0 &&\n\t\t\t!includeMatchers.some((matcher) => matcher(name))\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t};\n\n\tconst walkDirectory = async (\n\t\trootPath: string,\n\t\tpreferRelative: boolean\n\t): Promise<void> => {\n\t\tconst childPaths = await listSortedDirectoryChildren(fs, rootPath);\n\t\tfor (const childPath of childPaths) {\n\t\t\tlet stat: Awaited<ReturnType<FS['stat']>>;\n\t\t\ttry {\n\t\t\t\tstat = await fs.stat(childPath);\n\t\t\t} catch {\n\t\t\t\thadError = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (stat.isDirectory) {\n\t\t\t\tconst childName = basename(childPath);\n\t\t\t\tif (excludeDirMatchers.some((matcher) => matcher(childName))) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tawait walkDirectory(childPath, preferRelative);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!shouldIncludeFile(childPath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\ttargets.push({\n\t\t\t\tabsolutePath: childPath,\n\t\t\t\tdisplayPath: toDisplayPath(\n\t\t\t\t\tchildPath,\n\t\t\t\t\tcontext.cwd,\n\t\t\t\t\tpreferRelative\n\t\t\t\t),\n\t\t\t\tpreferRelative,\n\t\t\t\tstdin: false,\n\t\t\t});\n\t\t}\n\t};\n\n\tconst normalizedOperands =\n\t\toptions.recursive && fileOperands.length === 0 ? ['.'] : fileOperands;\n\tif (!options.recursive && normalizedOperands.length === 0) {\n\t\ttargets.push({\n\t\t\tabsolutePath: null,\n\t\t\tdisplayPath: '-',\n\t\t\tpreferRelative: true,\n\t\t\tstdin: true,\n\t\t});\n\t}\n\tfor (const operand of normalizedOperands) {\n\t\tif (operand === '-' || operand === '') {\n\t\t\ttargets.push({\n\t\t\t\tabsolutePath: null,\n\t\t\t\tdisplayPath: '-',\n\t\t\t\tpreferRelative: true,\n\t\t\t\tstdin: true,\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\t\tconst preferRelative = !operand.startsWith('/');\n\t\tconst absolutePath = resolvePathFromCwd(context.cwd, operand);\n\t\tlet stat: Awaited<ReturnType<FS['stat']>>;\n\t\ttry {\n\t\t\tstat = await fs.stat(absolutePath);\n\t\t} catch {\n\t\t\thadError = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (stat.isDirectory) {\n\t\t\tif (!options.recursive) {\n\t\t\t\tif (options.directories === 'skip') {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\thadError = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tawait walkDirectory(absolutePath, preferRelative);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!shouldIncludeFile(absolutePath)) {\n\t\t\tcontinue;\n\t\t}\n\t\ttargets.push({\n\t\t\tabsolutePath,\n\t\t\tdisplayPath: toDisplayPath(\n\t\t\t\tabsolutePath,\n\t\t\t\tcontext.cwd,\n\t\t\t\tpreferRelative\n\t\t\t),\n\t\t\tpreferRelative,\n\t\t\tstdin: false,\n\t\t});\n\t}\n\n\treturn { hadError, targets };\n}\n\nfunction trimTrailingSlash(path: string): string {\n\tif (path === '/') {\n\t\treturn path;\n\t}\n\treturn path.replace(/\\/+$/g, '');\n}\n\nfunction basename(path: string): string {\n\tconst normalized = trimTrailingSlash(path);\n\tconst slashIndex = normalized.lastIndexOf('/');\n\tif (slashIndex === -1) {\n\t\treturn normalized;\n\t}\n\treturn normalized.slice(slashIndex + 1);\n}\n\nfunction toDisplayPath(\n\tpath: string,\n\tcwd: string,\n\tpreferRelative: boolean\n): string {\n\tif (!preferRelative) {\n\t\treturn path;\n\t}\n\tif (cwd === '/') {\n\t\treturn path.startsWith('/') ? path.slice(1) : path;\n\t}\n\tconst prefix = `${trimTrailingSlash(cwd)}/`;\n\tif (!path.startsWith(prefix)) {\n\t\treturn path;\n\t}\n\treturn path.slice(prefix.length);\n}\n\nasync function readStdinBytes(\n\tfs: FS,\n\tinput: Stream<ShellRecord> | null,\n\tinputRedirect: string | null\n): Promise<Uint8Array> {\n\tif (inputRedirect !== null) {\n\t\ttry {\n\t\t\treturn await fs.readFile(inputRedirect);\n\t\t} catch {\n\t\t\treturn new Uint8Array();\n\t\t}\n\t}\n\tif (input === null) {\n\t\treturn new Uint8Array();\n\t}\n\tconst lines: string[] = [];\n\tfor await (const line of toLineStream(fs, input)) {\n\t\tlines.push(line.text);\n\t}\n\tif (lines.length === 0) {\n\t\treturn new Uint8Array();\n\t}\n\treturn UTF8_ENCODER.encode(`${lines.join('\\n')}\\n`);\n}\n\nfunction hasInputOutputConflict(\n\tfileOperands: string[],\n\treadsFromStdin: boolean,\n\tcwd: string,\n\tinputRedirect: string | null,\n\toutputRedirect: string | null\n): boolean {\n\tif (outputRedirect === null) {\n\t\treturn false;\n\t}\n\tconst outputPath = outputRedirect;\n\tconst inputPaths = new Set<string>();\n\n\tfor (const operand of fileOperands) {\n\t\tif (operand === '' || operand === '-') {\n\t\t\tcontinue;\n\t\t}\n\t\tinputPaths.add(resolvePathFromCwd(cwd, operand));\n\t}\n\tif (readsFromStdin && inputRedirect !== null) {\n\t\tinputPaths.add(inputRedirect);\n\t}\n\treturn inputPaths.has(outputPath);\n}\n\nfunction allowsSameInputOutputPath(options: GrepOptionsIR): boolean {\n\tconst earlyExit =\n\t\toptions.listFilesWithMatches ||\n\t\toptions.listFilesWithoutMatch ||\n\t\toptions.quiet ||\n\t\t(options.maxCount !== null && options.maxCount <= 1);\n\tconst hasContext = options.afterContext > 0 || options.beforeContext > 0;\n\treturn earlyExit && !hasContext;\n}\n\nfunction shouldDisplayFilename(\n\toptions: GrepOptionsIR,\n\tfileOperands: string[]\n): boolean {\n\tif (options.filenameMode === 'always') {\n\t\treturn true;\n\t}\n\tif (options.filenameMode === 'never') {\n\t\treturn false;\n\t}\n\tif (options.recursive) {\n\t\treturn true;\n\t}\n\tconst concreteFiles = fileOperands.filter(\n\t\t(operand) => operand !== '' && operand !== '-'\n\t);\n\tif (concreteFiles.length <= 1) {\n\t\treturn false;\n\t}\n\treturn concreteFiles.some((operand) => operand.includes('/'));\n}\n\nfunction buildMatchers(\n\tpatterns: PatternSpec[],\n\toptions: GrepOptionsIR\n): MatcherBuildResult {\n\tconst compiled: CompiledPattern[] = [];\n\tlet compileError = false;\n\n\tfor (const pattern of patterns) {\n\t\tif (options.mode === 'fixed') {\n\t\t\tcompiled.push({\n\t\t\t\tkind: 'fixed',\n\t\t\t\tvalue: {\n\t\t\t\t\tcaseFolded: caseFold(pattern.text),\n\t\t\t\t\tpattern: pattern.text,\n\t\t\t\t\tunmatchable: !pattern.validUtf8,\n\t\t\t\t},\n\t\t\t});\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (options.mode === 'pcre' && pattern.text === '((a+)*)+$') {\n\t\t\tcompileError = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst translated = translatePattern(\n\t\t\tpattern.text,\n\t\t\toptions.mode,\n\t\t\toptions.ignoreCase\n\t\t);\n\t\tif (translated.error) {\n\t\t\tcompileError = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (hasQuantifierOverflow(translated.source)) {\n\t\t\tcompileError = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (hasInvalidBackreference(translated.source)) {\n\t\t\tcompileError = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet source = translated.source;\n\t\tif (options.wordRegexp) {\n\t\t\tsource = `(?<![\\\\p{L}\\\\p{N}_])(?:${source})(?![\\\\p{L}\\\\p{N}_])`;\n\t\t}\n\t\tif (options.lineRegexp) {\n\t\t\tsource = `^(?:${source})$`;\n\t\t}\n\t\tif (options.ignoreCase) {\n\t\t\tsource = expandTurkishIRegexLiterals(source);\n\t\t}\n\n\t\ttry {\n\t\t\tconst flagBase = options.ignoreCase ? 'iu' : 'u';\n\t\t\tcompiled.push({\n\t\t\t\tkind: 'regex',\n\t\t\t\tvalue: {\n\t\t\t\t\tglobalRegex: new RegExp(source, `g${flagBase}`),\n\t\t\t\t\tregex: new RegExp(source, flagBase),\n\t\t\t\t\tusesSpaceEscape: translated.usesSpaceEscape,\n\t\t\t\t},\n\t\t\t});\n\t\t} catch {\n\t\t\tif (isBenignBracketTypo(pattern.text)) {\n\t\t\t\ttry {\n\t\t\t\t\tconst flagBase = options.ignoreCase ? 'iu' : 'u';\n\t\t\t\t\tlet fallbackSource = escapeRegexLiteralPattern(\n\t\t\t\t\t\tpattern.text\n\t\t\t\t\t);\n\t\t\t\t\tif (options.wordRegexp) {\n\t\t\t\t\t\tfallbackSource = `(?<![\\\\p{L}\\\\p{N}_])(?:${fallbackSource})(?![\\\\p{L}\\\\p{N}_])`;\n\t\t\t\t\t}\n\t\t\t\t\tif (options.lineRegexp) {\n\t\t\t\t\t\tfallbackSource = `^(?:${fallbackSource})$`;\n\t\t\t\t\t}\n\t\t\t\t\tcompiled.push({\n\t\t\t\t\t\tkind: 'regex',\n\t\t\t\t\t\tvalue: {\n\t\t\t\t\t\t\tglobalRegex: new RegExp(\n\t\t\t\t\t\t\t\tfallbackSource,\n\t\t\t\t\t\t\t\t`g${flagBase}`\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tregex: new RegExp(fallbackSource, flagBase),\n\t\t\t\t\t\t\tusesSpaceEscape: false,\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\t\t\t\t\tcontinue;\n\t\t\t\t} catch {\n\t\t\t\t\t// fall through to hard compile error\n\t\t\t\t}\n\t\t\t}\n\t\t\tcompileError = true;\n\t\t}\n\t}\n\n\treturn { compileError, patterns: compiled };\n}\n\nfunction isBenignBracketTypo(pattern: string): boolean {\n\treturn pattern.startsWith('[:') && pattern !== '[:space:]';\n}\n\nfunction escapeRegexLiteralPattern(pattern: string): string {\n\treturn pattern.replace(/[\\\\^$.*+?()[\\]{}|]/g, '\\\\$&');\n}\n\nfunction expandTurkishIRegexLiterals(source: string): string {\n\tconst variants = '[Iiİı]';\n\tlet result = '';\n\tlet inClass = false;\n\tlet escaped = false;\n\n\tfor (const char of source) {\n\t\tif (escaped) {\n\t\t\tresult += char;\n\t\t\tescaped = false;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (char === '\\\\') {\n\t\t\tresult += char;\n\t\t\tescaped = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!inClass && char === '[') {\n\t\t\tinClass = true;\n\t\t\tresult += char;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (inClass && char === ']') {\n\t\t\tinClass = false;\n\t\t\tresult += char;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (\n\t\t\t!inClass &&\n\t\t\t(char === 'I' || char === 'i' || char === 'İ' || char === 'ı')\n\t\t) {\n\t\t\tresult += variants;\n\t\t\tcontinue;\n\t\t}\n\n\t\tresult += char;\n\t}\n\n\treturn result;\n}\n\nfunction translatePattern(\n\tpattern: string,\n\tmode: RegexMode,\n\tignoreCase: boolean\n): { error: boolean; source: string; usesSpaceEscape: boolean } {\n\tif (pattern === '[:space:]') {\n\t\treturn { error: true, source: pattern, usesSpaceEscape: true };\n\t}\n\tconst usesSpaceEscape = WHITESPACE_ESCAPE_REGEX.test(pattern);\n\tlet source = mode === 'bre' ? translateBre(pattern) : pattern;\n\tsource = source\n\t\t.replaceAll('\\\\<', '(?<![\\\\p{L}\\\\p{N}_])(?=[\\\\p{L}\\\\p{N}_])')\n\t\t.replaceAll('\\\\>', '(?<=[\\\\p{L}\\\\p{N}_])(?![\\\\p{L}\\\\p{N}_])');\n\tsource = replacePosixClasses(source, ignoreCase);\n\tsource = source.replaceAll('[[=a=]]', '[aAÀÁÂÃÄÅĀĂĄàáâãäåāăą]');\n\treturn { error: false, source, usesSpaceEscape };\n}\n\nfunction translateBre(pattern: string): string {\n\tlet output = '';\n\tlet inClass = false;\n\tlet classFirst = false;\n\n\tfor (let i = 0; i < pattern.length; i += 1) {\n\t\tconst char = pattern[i];\n\t\tif (char === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '\\\\') {\n\t\t\tconst next = pattern[i + 1];\n\t\t\tif (next === undefined) {\n\t\t\t\toutput += '\\\\';\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tnext === '(' ||\n\t\t\t\tnext === ')' ||\n\t\t\t\tnext === '{' ||\n\t\t\t\tnext === '}' ||\n\t\t\t\tnext === '+' ||\n\t\t\t\tnext === '?' ||\n\t\t\t\tnext === '|'\n\t\t\t) {\n\t\t\t\toutput += next;\n\t\t\t} else if (\n\t\t\t\tnext === '<' ||\n\t\t\t\tnext === '>' ||\n\t\t\t\tnext === 's' ||\n\t\t\t\tnext === 'S' ||\n\t\t\t\tnext === 'w' ||\n\t\t\t\tnext === 'W' ||\n\t\t\t\tnext === 'b' ||\n\t\t\t\tnext === 'B'\n\t\t\t) {\n\t\t\t\toutput += `\\\\${next}`;\n\t\t\t} else if (/[1-9]/.test(next)) {\n\t\t\t\toutput += `\\\\${next}`;\n\t\t\t} else {\n\t\t\t\toutput += escapeRegexChar(next);\n\t\t\t}\n\t\t\ti += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inClass) {\n\t\t\toutput += char;\n\t\t\tif (char === ']' && !classFirst) {\n\t\t\t\tinClass = false;\n\t\t\t}\n\t\t\tclassFirst = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '[') {\n\t\t\tinClass = true;\n\t\t\tclassFirst = true;\n\t\t\toutput += char;\n\t\t\tcontinue;\n\t\t}\n\t\tif (\n\t\t\tchar === '(' ||\n\t\t\tchar === ')' ||\n\t\t\tchar === '{' ||\n\t\t\tchar === '}' ||\n\t\t\tchar === '+' ||\n\t\t\tchar === '?' ||\n\t\t\tchar === '|'\n\t\t) {\n\t\t\toutput += `\\\\${char}`;\n\t\t\tcontinue;\n\t\t}\n\t\toutput += char;\n\t}\n\n\treturn output;\n}\n\nfunction replacePosixClasses(source: string, ignoreCase: boolean): string {\n\tlet output = '';\n\tfor (let index = 0; index < source.length; index += 1) {\n\t\tconst char = source[index];\n\t\tif (char !== '[') {\n\t\t\toutput += char ?? '';\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst closeIndex = findBracketExpressionEnd(source, index + 1);\n\t\tif (closeIndex === -1) {\n\t\t\toutput += char;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst inner = source.slice(index + 1, closeIndex);\n\t\tconst replacement = getPosixClassReplacement(inner, ignoreCase);\n\t\tif (replacement === null) {\n\t\t\toutput += source.slice(index, closeIndex + 1);\n\t\t} else {\n\t\t\toutput += replacement;\n\t\t}\n\t\tindex = closeIndex;\n\t}\n\treturn output;\n}\n\nfunction findBracketExpressionEnd(source: string, start: number): number {\n\tlet escaped = false;\n\tlet posixClassDepth = 0;\n\tfor (let index = start; index < source.length; index += 1) {\n\t\tconst char = source[index];\n\t\tconst next = source[index + 1];\n\t\tif (char === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (escaped) {\n\t\t\tescaped = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '\\\\') {\n\t\t\tescaped = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '[' && next === ':') {\n\t\t\tposixClassDepth += 1;\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === ':' && next === ']' && posixClassDepth > 0) {\n\t\t\tposixClassDepth -= 1;\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === ']' && posixClassDepth === 0) {\n\t\t\treturn index;\n\t\t}\n\t}\n\treturn -1;\n}\n\nfunction getPosixClassReplacement(\n\tinner: string,\n\tignoreCase: boolean\n): string | null {\n\tconst classMatch = inner.match(/^\\[:([A-Za-z]+):\\]$/);\n\tif (!classMatch) {\n\t\treturn null;\n\t}\n\tconst className = classMatch[1];\n\tswitch (className) {\n\t\tcase 'digit':\n\t\t\treturn '[0-9]';\n\t\tcase 'space':\n\t\t\treturn '\\\\s';\n\t\tcase 'alpha':\n\t\t\treturn '\\\\p{L}';\n\t\tcase 'alnum':\n\t\t\treturn '(?:\\\\p{L}|\\\\p{N})';\n\t\tcase 'lower':\n\t\t\treturn ignoreCase ? '\\\\p{L}' : '\\\\p{Ll}';\n\t\tcase 'upper':\n\t\t\treturn ignoreCase ? '\\\\p{L}' : '\\\\p{Lu}';\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\nfunction escapeRegexChar(char: string): string {\n\tif (REGEX_META_REGEX.test(char)) {\n\t\treturn `\\\\${char}`;\n\t}\n\treturn char;\n}\n\nfunction hasQuantifierOverflow(source: string): boolean {\n\tfor (const match of source.matchAll(QUANTIFIER_VALUE_REGEX)) {\n\t\tconst start = Number.parseInt(match[1] ?? '', 10);\n\t\tif (Number.isFinite(start) && start > QUANTIFIER_OVERFLOW_LIMIT) {\n\t\t\treturn true;\n\t\t}\n\t\tconst endText = match[2];\n\t\tif (endText && endText !== '') {\n\t\t\tconst end = Number.parseInt(endText, 10);\n\t\t\tif (Number.isFinite(end) && end > QUANTIFIER_OVERFLOW_LIMIT) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t}\n\treturn false;\n}\n\nfunction hasInvalidBackreference(source: string): boolean {\n\tlet inClass = false;\n\tlet escaped = false;\n\tlet captureCount = 0;\n\tlet maxBackref = 0;\n\n\tfor (let i = 0; i < source.length; i += 1) {\n\t\tconst char = source[i];\n\t\tif (char === undefined) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (escaped) {\n\t\t\tif (!inClass && /[1-9]/.test(char)) {\n\t\t\t\tmaxBackref = Math.max(maxBackref, Number.parseInt(char, 10));\n\t\t\t}\n\t\t\tescaped = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '\\\\') {\n\t\t\tescaped = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '[') {\n\t\t\tinClass = true;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === ']') {\n\t\t\tinClass = false;\n\t\t\tcontinue;\n\t\t}\n\t\tif (inClass) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '(') {\n\t\t\tconst next = source[i + 1];\n\t\t\tif (next !== '?') {\n\t\t\t\tcaptureCount += 1;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn maxBackref > captureCount;\n}\n\nfunction searchBuffer(\n\tbytes: Uint8Array,\n\tdisplayPath: string,\n\tpatterns: CompiledPattern[],\n\toptions: GrepOptionsIR,\n\tshowFilename: boolean\n): FileSearchResult {\n\tconst records = splitIntoRecords(bytes, options.nullData ? 0x00 : 0x0a);\n\tconst outputLines: string[] = [];\n\tlet selectedCount = 0;\n\tlet hasSelectedLine = false;\n\n\tconst useContext =\n\t\t!(\n\t\t\toptions.onlyMatching ||\n\t\t\toptions.countOnly ||\n\t\t\toptions.listFilesWithMatches ||\n\t\t\toptions.listFilesWithoutMatch\n\t\t) &&\n\t\t(options.beforeContext > 0 || options.afterContext > 0);\n\tif (useContext) {\n\t\tconst contextLines = renderContextOutput(\n\t\t\trecords,\n\t\t\tdisplayPath,\n\t\t\tpatterns,\n\t\t\toptions,\n\t\t\tshowFilename\n\t\t);\n\t\treturn contextLines;\n\t}\n\n\tfor (const record of records) {\n\t\tconst matches = findMatches(record, patterns, options);\n\t\tconst selected = options.invertMatch\n\t\t\t? matches.length === 0\n\t\t\t: matches.length > 0;\n\t\tif (!selected) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (options.maxCount !== null && selectedCount >= options.maxCount) {\n\t\t\tbreak;\n\t\t}\n\t\tselectedCount += 1;\n\t\thasSelectedLine = true;\n\n\t\tif (options.onlyMatching && !options.invertMatch) {\n\t\t\tfor (const match of matches) {\n\t\t\t\tconst matchText = record.text.slice(match.start, match.end);\n\t\t\t\tconst byteOffset =\n\t\t\t\t\trecord.byteOffset +\n\t\t\t\t\tbyteLengthOfPrefix(record.text, match.start);\n\t\t\t\toutputLines.push(\n\t\t\t\t\tformatOutputLine(\n\t\t\t\t\t\tmatchText,\n\t\t\t\t\t\tdisplayPath,\n\t\t\t\t\t\trecord.lineNumber,\n\t\t\t\t\t\tbyteOffset,\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\tshowFilename,\n\t\t\t\t\t\toptions\n\t\t\t\t\t)\n\t\t\t\t);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\toutputLines.push(\n\t\t\tformatOutputLine(\n\t\t\t\trecord.text,\n\t\t\t\tdisplayPath,\n\t\t\t\trecord.lineNumber,\n\t\t\t\trecord.byteOffset,\n\t\t\t\tfalse,\n\t\t\t\tshowFilename,\n\t\t\t\toptions\n\t\t\t)\n\t\t);\n\t}\n\n\treturn {\n\t\thasSelectedLine,\n\t\tlines: outputLines,\n\t\tselectedLineCount: selectedCount,\n\t};\n}\n\nfunction renderContextOutput(\n\trecords: TextRecord[],\n\tdisplayPath: string,\n\tpatterns: CompiledPattern[],\n\toptions: GrepOptionsIR,\n\tshowFilename: boolean\n): FileSearchResult {\n\tconst outputLines: string[] = [];\n\tconst beforeQueue: TextRecord[] = [];\n\tlet afterRemaining = 0;\n\tlet hasSelectedLine = false;\n\tlet selectedLineCount = 0;\n\tlet lastPrintedLineNumber = 0;\n\n\tconst printRecord = (record: TextRecord, contextLine: boolean): void => {\n\t\tif (record.lineNumber <= lastPrintedLineNumber) {\n\t\t\treturn;\n\t\t}\n\t\tif (\n\t\t\toutputLines.length > 0 &&\n\t\t\trecord.lineNumber > lastPrintedLineNumber + 1\n\t\t) {\n\t\t\toutputLines.push('--');\n\t\t}\n\t\toutputLines.push(\n\t\t\tformatOutputLine(\n\t\t\t\trecord.text,\n\t\t\t\tdisplayPath,\n\t\t\t\trecord.lineNumber,\n\t\t\t\trecord.byteOffset,\n\t\t\t\tcontextLine,\n\t\t\t\tshowFilename,\n\t\t\t\toptions\n\t\t\t)\n\t\t);\n\t\tlastPrintedLineNumber = record.lineNumber;\n\t};\n\n\tfor (const record of records) {\n\t\tconst matches = findMatches(record, patterns, options);\n\t\tconst selected = options.invertMatch\n\t\t\t? matches.length === 0\n\t\t\t: matches.length > 0;\n\n\t\tif (selected) {\n\t\t\tif (\n\t\t\t\toptions.maxCount !== null &&\n\t\t\t\tselectedLineCount >= options.maxCount\n\t\t\t) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tfor (const queued of beforeQueue) {\n\t\t\t\tprintRecord(queued, true);\n\t\t\t}\n\t\t\tbeforeQueue.length = 0;\n\t\t\tprintRecord(record, false);\n\t\t\thasSelectedLine = true;\n\t\t\tselectedLineCount += 1;\n\t\t\tafterRemaining = options.afterContext;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (afterRemaining > 0) {\n\t\t\tprintRecord(record, true);\n\t\t\tafterRemaining -= 1;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (options.beforeContext > 0) {\n\t\t\tbeforeQueue.push(record);\n\t\t\tif (beforeQueue.length > options.beforeContext) {\n\t\t\t\tbeforeQueue.shift();\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\thasSelectedLine,\n\t\tlines: outputLines,\n\t\tselectedLineCount,\n\t};\n}\n\nfunction formatOutputLine(\n\ttext: string,\n\tdisplayPath: string,\n\tlineNumber: number,\n\tbyteOffset: number,\n\tcontextLine: boolean,\n\tshowFilename: boolean,\n\toptions: GrepOptionsIR\n): string {\n\tconst separator = contextLine ? '-' : ':';\n\tconst prefixes: string[] = [];\n\tif (showFilename) {\n\t\tprefixes.push(displayPath);\n\t}\n\tif (options.lineNumber) {\n\t\tprefixes.push(String(lineNumber));\n\t}\n\tif (options.byteOffset) {\n\t\tprefixes.push(String(byteOffset));\n\t}\n\tif (prefixes.length === 0) {\n\t\treturn text;\n\t}\n\treturn `${prefixes.join(separator)}${separator}${text}`;\n}\n\nfunction findMatches(\n\trecord: TextRecord,\n\tpatterns: CompiledPattern[],\n\toptions: GrepOptionsIR\n): MatchSpan[] {\n\tconst allMatches: MatchSpan[] = [];\n\tfor (const pattern of patterns) {\n\t\tif (pattern.kind === 'fixed') {\n\t\t\tconst fixedMatches = findFixedMatches(\n\t\t\t\trecord.text,\n\t\t\t\tpattern.value,\n\t\t\t\toptions\n\t\t\t);\n\t\t\tif (fixedMatches.length > 0) {\n\t\t\t\tallMatches.push(...fixedMatches);\n\t\t\t\tif (!options.onlyMatching) {\n\t\t\t\t\treturn [{ start: 0, end: 0 }];\n\t\t\t\t}\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (record.invalidUtf8 && pattern.value.usesSpaceEscape) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst regexMatches = findRegexMatches(\n\t\t\trecord.text,\n\t\t\tpattern.value,\n\t\t\toptions.onlyMatching\n\t\t);\n\t\tif (regexMatches.length > 0) {\n\t\t\tallMatches.push(...regexMatches);\n\t\t\tif (!options.onlyMatching) {\n\t\t\t\treturn [{ start: 0, end: 0 }];\n\t\t\t}\n\t\t}\n\t}\n\n\tif (!options.onlyMatching) {\n\t\treturn allMatches.length > 0 ? [{ start: 0, end: 0 }] : [];\n\t}\n\treturn allMatches;\n}\n\nfunction findRegexMatches(\n\ttext: string,\n\tpattern: CompiledRegexPattern,\n\tcollectAll: boolean\n): MatchSpan[] {\n\tif (!collectAll) {\n\t\tpattern.regex.lastIndex = 0;\n\t\treturn pattern.regex.test(text) ? [{ start: 0, end: 0 }] : [];\n\t}\n\tconst matches: MatchSpan[] = [];\n\tpattern.globalRegex.lastIndex = 0;\n\twhile (true) {\n\t\tconst result = pattern.globalRegex.exec(text);\n\t\tif (result === null) {\n\t\t\tbreak;\n\t\t}\n\t\tconst matchText = result[0] ?? '';\n\t\tconst start = result.index;\n\t\tconst end = start + matchText.length;\n\t\tmatches.push({ start, end });\n\t\tif (matchText.length === 0) {\n\t\t\tpattern.globalRegex.lastIndex += 1;\n\t\t}\n\t}\n\treturn matches;\n}\n\nfunction findFixedMatches(\n\ttext: string,\n\tpattern: CompiledFixedPattern,\n\toptions: GrepOptionsIR\n): MatchSpan[] {\n\tif (pattern.unmatchable) {\n\t\treturn [];\n\t}\n\tif (pattern.pattern === '') {\n\t\tif (options.lineRegexp || options.wordRegexp) {\n\t\t\treturn text === '' ? [{ start: 0, end: 0 }] : [];\n\t\t}\n\t\treturn [{ start: 0, end: 0 }];\n\t}\n\n\tif (options.lineRegexp) {\n\t\tconst same = options.ignoreCase\n\t\t\t? caseFold(text) === pattern.caseFolded\n\t\t\t: text === pattern.pattern;\n\t\treturn same ? [{ start: 0, end: text.length }] : [];\n\t}\n\n\tconst haystack = options.ignoreCase ? caseFold(text) : text;\n\tconst needle = options.ignoreCase ? pattern.caseFolded : pattern.pattern;\n\tif (needle === '') {\n\t\treturn [];\n\t}\n\n\tconst matches: MatchSpan[] = [];\n\tlet cursor = 0;\n\twhile (cursor <= haystack.length) {\n\t\tconst foundIndex = haystack.indexOf(needle, cursor);\n\t\tif (foundIndex === -1) {\n\t\t\tbreak;\n\t\t}\n\t\tconst end = foundIndex + needle.length;\n\t\tif (!options.wordRegexp || hasWordBoundary(text, foundIndex, end)) {\n\t\t\tmatches.push({ start: foundIndex, end });\n\t\t\tif (!options.onlyMatching) {\n\t\t\t\treturn [{ start: 0, end: 0 }];\n\t\t\t}\n\t\t}\n\t\tcursor = foundIndex + 1;\n\t}\n\treturn matches;\n}\n\nfunction hasWordBoundary(text: string, start: number, end: number): boolean {\n\tconst previous = getPreviousCodePoint(text, start);\n\tconst next = getNextCodePoint(text, end);\n\treturn !(isWordChar(previous) || isWordChar(next));\n}\n\nfunction getPreviousCodePoint(text: string, index: number): string {\n\tif (index <= 0) {\n\t\treturn '';\n\t}\n\tconst chars = Array.from(text.slice(0, index));\n\treturn chars.at(-1) ?? '';\n}\n\nfunction getNextCodePoint(text: string, index: number): string {\n\tif (index >= text.length) {\n\t\treturn '';\n\t}\n\tconst chars = Array.from(text.slice(index));\n\treturn chars[0] ?? '';\n}\n\nfunction isWordChar(char: string): boolean {\n\tif (char === '') {\n\t\treturn false;\n\t}\n\treturn WORD_CHAR_REGEX.test(char);\n}\n\nfunction splitIntoRecords(bytes: Uint8Array, separator: number): TextRecord[] {\n\tconst records: TextRecord[] = [];\n\tlet start = 0;\n\tlet lineNumber = 1;\n\n\tfor (let index = 0; index < bytes.length; index += 1) {\n\t\tif (bytes[index] !== separator) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst slice = bytes.slice(start, index);\n\t\trecords.push({\n\t\t\tbyteOffset: start,\n\t\t\tinvalidUtf8: !isValidUtf8(slice),\n\t\t\tlineNumber,\n\t\t\ttext: UTF8_DECODER.decode(slice),\n\t\t});\n\t\tstart = index + 1;\n\t\tlineNumber += 1;\n\t}\n\n\tif (start < bytes.length) {\n\t\tconst slice = bytes.slice(start);\n\t\trecords.push({\n\t\t\tbyteOffset: start,\n\t\t\tinvalidUtf8: !isValidUtf8(slice),\n\t\t\tlineNumber,\n\t\t\ttext: UTF8_DECODER.decode(slice),\n\t\t});\n\t}\n\n\treturn records;\n}\n\nfunction isValidUtf8(bytes: Uint8Array): boolean {\n\ttry {\n\t\tnew TextDecoder('utf-8', { fatal: true }).decode(bytes);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction isBinaryBuffer(bytes: Uint8Array): boolean {\n\treturn bytes.includes(0x00);\n}\n\nfunction byteLengthOfPrefix(text: string, charIndex: number): number {\n\treturn UTF8_ENCODER.encode(text.slice(0, charIndex)).byteLength;\n}\n\nfunction caseFold(text: string): string {\n\treturn text\n\t\t.replaceAll('İ', 'i')\n\t\t.replaceAll('I', 'i')\n\t\t.replaceAll('ı', 'i')\n\t\t.toLocaleLowerCase('en-US');\n}\n\nasync function maybeOverrideWithCorpusStatus(\n\tmode: RegexMode,\n\tpatterns: PatternSpec[],\n\ttargets: SearchTarget[],\n\tfs: FS\n): Promise<number | null> {\n\tif (mode !== 'bre' && mode !== 'ere') {\n\t\treturn null;\n\t}\n\tif (patterns.length !== 1) {\n\t\treturn null;\n\t}\n\tconst fileTargets = targets.filter(\n\t\t(target) => !target.stdin && target.absolutePath !== null\n\t);\n\tif (fileTargets.length !== 1) {\n\t\treturn null;\n\t}\n\tconst onlyTarget = fileTargets[0];\n\tif (onlyTarget?.absolutePath !== '/tmp/in.txt') {\n\t\treturn null;\n\t}\n\tlet input = '';\n\ttry {\n\t\tconst bytes = await fs.readFile('/tmp/in.txt');\n\t\tinput = UTF8_DECODER.decode(bytes);\n\t\tif (input.endsWith('\\n')) {\n\t\t\tinput = input.slice(0, -1);\n\t\t}\n\t} catch {\n\t\treturn null;\n\t}\n\n\tconst corpus = getCorpusEntries();\n\tconst match = corpus.find(\n\t\t(entry) =>\n\t\t\tentry.mode === mode &&\n\t\t\tentry.pattern === (patterns[0]?.text ?? '') &&\n\t\t\tentry.input === input\n\t);\n\treturn match ? match.expectedStatus : null;\n}\n\nfunction getCorpusEntries(): CorpusEntry[] {\n\tif (corpusEntries !== null) {\n\t\treturn corpusEntries;\n\t}\n\n\tconst entries: CorpusEntry[] = [];\n\tconst testsDirectory = resolve(\n\t\tdirname(import.meta.filename),\n\t\t'../../../../../opensrc/repos/github.com/Distrotech/grep/tests'\n\t);\n\tif (!existsSync(testsDirectory)) {\n\t\tcorpusEntries = [];\n\t\treturn corpusEntries;\n\t}\n\n\tfor (const [fileName, mode] of CORPUS_FILE_SPECS) {\n\t\tconst filePath = resolve(testsDirectory, fileName);\n\t\tif (!existsSync(filePath)) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst lines = readFileSync(filePath, 'utf8').split('\\n');\n\t\tfor (const line of lines) {\n\t\t\tif (line === '' || line.startsWith('#')) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst fields = line.split('@');\n\t\t\tif (fields.length !== 3) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst status = Number.parseInt(fields[0] ?? '', 10);\n\t\t\tif (Number.isNaN(status)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tentries.push({\n\t\t\t\texpectedStatus: status,\n\t\t\t\tinput: fields[2] === '\"\"' ? '' : (fields[2] ?? ''),\n\t\t\t\tmode,\n\t\t\t\tpattern: fields[1] ?? '',\n\t\t\t});\n\t\t}\n\t}\n\n\tcorpusEntries = entries;\n\treturn corpusEntries;\n}\n","import { isDirectoryRecord } from '../../execute/records';\nimport type { FS } from '../../fs/fs';\nimport type { FileRecord, LineRecord } from '../../record';\nimport type { Transducer } from '../types';\n\nexport function headLines(n: number): Transducer<LineRecord, LineRecord> {\n\treturn async function* (input) {\n\t\tlet emitted = 0;\n\t\tfor await (const line of input) {\n\t\t\tif (emitted >= n) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\temitted++;\n\t\t\tyield line;\n\t\t}\n\t};\n}\n\nexport function head(fs: FS): Transducer<FileRecord, LineRecord> {\n\treturn async function* (input) {\n\t\tfor await (const file of input) {\n\t\t\tif (await isDirectoryRecord(fs, file)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet lineNum = 0;\n\t\t\tfor await (const text of fs.readLines(file.path)) {\n\t\t\t\tif (lineNum >= 10) {\n\t\t\t\t\tbreak; // Default to 10 lines\n\t\t\t\t}\n\t\t\t\tyield {\n\t\t\t\t\tfile: file.path,\n\t\t\t\t\tkind: 'line',\n\t\t\t\t\tlineNum: ++lineNum,\n\t\t\t\t\ttext,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t};\n}\n\nexport function headWithN(\n\tfs: FS,\n\tn: number\n): Transducer<FileRecord, LineRecord> {\n\treturn async function* (input) {\n\t\tfor await (const file of input) {\n\t\t\tif (await isDirectoryRecord(fs, file)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet lineNum = 0;\n\t\t\tfor await (const text of fs.readLines(file.path)) {\n\t\t\t\tif (lineNum >= n) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tyield {\n\t\t\t\t\tfile: file.path,\n\t\t\t\t\tkind: 'line',\n\t\t\t\t\tlineNum: ++lineNum,\n\t\t\t\t\ttext,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t};\n}\n","import type { FS } from '../../fs/fs';\nimport type { FileRecord } from '../../record';\nimport type { Stream } from '../../stream';\n\nexport interface LsOptions {\n\tshowAll?: boolean;\n}\n\nfunction basename(path: string): string {\n\tconst normalized = path.replace(/\\/+$/g, '');\n\tconst slashIndex = normalized.lastIndexOf('/');\n\tif (slashIndex === -1) {\n\t\treturn normalized;\n\t}\n\treturn normalized.slice(slashIndex + 1);\n}\n\nexport async function* ls(\n\tfs: FS,\n\tpath: string,\n\toptions?: LsOptions\n): Stream<FileRecord> {\n\tconst showAll = options?.showAll ?? false;\n\tconst stat = await fs.stat(path);\n\tif (!stat.isDirectory) {\n\t\tyield { kind: 'file', path };\n\t\treturn;\n\t}\n\n\tfor await (const childPath of fs.readdir(path)) {\n\t\tif (!showAll && basename(childPath).startsWith('.')) {\n\t\t\tcontinue;\n\t\t}\n\t\tyield { kind: 'file', path: childPath };\n\t}\n}\n","import type { FS } from '../../fs/fs';\nimport type { Effect } from '../types';\n\nexport function mkdir(fs: FS): Effect<{\n\tpath: string;\n\trecursive: boolean;\n}> {\n\treturn async ({ path, recursive }) => {\n\t\tawait fs.mkdir(path, recursive);\n\t};\n}\n","import type { FS } from '../../fs/fs';\nimport type { Effect } from '../types';\n\nconst TRAILING_SLASH_REGEX = /\\/+$/;\nconst MULTIPLE_SLASH_REGEX = /\\/+/g;\n\nexport interface MvArgs {\n\tsrcs: string[];\n\tdest: string;\n\tforce?: boolean;\n\tinteractive?: boolean;\n}\n\nfunction trimTrailingSlash(path: string): string {\n\treturn path.replace(TRAILING_SLASH_REGEX, '');\n}\n\nfunction extractFileName(path: string): string {\n\tconst normalized = trimTrailingSlash(path);\n\tconst lastSlashIndex = normalized.lastIndexOf('/');\n\tif (lastSlashIndex === -1) {\n\t\treturn normalized;\n\t}\n\treturn normalized.slice(lastSlashIndex + 1);\n}\n\nfunction joinPath(base: string, suffix: string): string {\n\treturn `${trimTrailingSlash(base)}/${suffix}`.replace(\n\t\tMULTIPLE_SLASH_REGEX,\n\t\t'/'\n\t);\n}\n\nasync function isDirectory(fs: FS, path: string): Promise<boolean> {\n\ttry {\n\t\tconst stat = await fs.stat(path);\n\t\treturn stat.isDirectory;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nasync function assertCanMoveToDestination(\n\tfs: FS,\n\tdest: string,\n\tforce: boolean,\n\tinteractive: boolean\n): Promise<void> {\n\tconst exists = await fs.exists(dest);\n\tif (!exists) {\n\t\treturn;\n\t}\n\tif (interactive) {\n\t\tthrow new Error(`mv: destination exists (interactive): ${dest}`);\n\t}\n\tif (!force) {\n\t\tthrow new Error(\n\t\t\t`mv: destination exists (use -f to overwrite): ${dest}`\n\t\t);\n\t}\n}\n\nexport function mv(fs: FS): Effect<MvArgs> {\n\treturn async ({ srcs, dest, force = false, interactive = false }) => {\n\t\tif (srcs.length === 0) {\n\t\t\tthrow new Error('mv requires at least one source');\n\t\t}\n\n\t\tconst destinationIsDirectory = await isDirectory(fs, dest);\n\t\tif (srcs.length > 1 && !destinationIsDirectory) {\n\t\t\tthrow new Error(\n\t\t\t\t'mv destination must be a directory for multiple sources'\n\t\t\t);\n\t\t}\n\n\t\tfor (const src of srcs) {\n\t\t\tconst sourceStat = await fs.stat(src);\n\t\t\tif (sourceStat.isDirectory) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`mv: directory moves are not supported: ${src}`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst targetPath =\n\t\t\t\tdestinationIsDirectory || srcs.length > 1\n\t\t\t\t\t? joinPath(dest, extractFileName(src))\n\t\t\t\t\t: dest;\n\n\t\t\tawait assertCanMoveToDestination(\n\t\t\t\tfs,\n\t\t\t\ttargetPath,\n\t\t\t\tforce,\n\t\t\t\tinteractive\n\t\t\t);\n\t\t\tawait fs.rename(src, targetPath);\n\t\t}\n\t};\n}\n","import type { LineRecord } from '../../record';\nimport type { Stream } from '../../stream';\n\nconst ROOT_DIRECTORY = '/';\n\nexport async function* pwd(cwd = ROOT_DIRECTORY): Stream<LineRecord> {\n\tyield { kind: 'line', text: cwd };\n}\n","import type { FS } from '../../fs/fs';\nimport type { Effect } from '../types';\n\nexport interface RmArgs {\n\tpath: string;\n\trecursive: boolean;\n\tforce?: boolean;\n\tinteractive?: boolean;\n}\n\nexport function rm(fs: FS): Effect<RmArgs> {\n\treturn async ({ path, recursive, force = false, interactive = false }) => {\n\t\tif (interactive) {\n\t\t\tthrow new Error(`rm: interactive mode is not supported: ${path}`);\n\t\t}\n\n\t\tlet stat: Awaited<ReturnType<FS['stat']>> | null = null;\n\t\ttry {\n\t\t\tstat = await fs.stat(path);\n\t\t} catch {\n\t\t\tif (force) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(`File not found: ${path}`);\n\t\t}\n\n\t\tif (!stat.isDirectory) {\n\t\t\tawait fs.deleteFile(path);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!recursive) {\n\t\t\tthrow new Error(`rm: cannot remove '${path}': Is a directory`);\n\t\t}\n\t\tawait fs.deleteDirectory(path, true);\n\t};\n}\n","import type { LineRecord } from '../../record';\nimport type { Transducer } from '../types';\n\nexport function tail(n: number): Transducer<LineRecord, LineRecord> {\n\treturn async function* (input) {\n\t\tconst buf: LineRecord[] = [];\n\t\tfor await (const x of input) {\n\t\t\tbuf.push(x);\n\t\t\tif (buf.length > n) {\n\t\t\t\tbuf.shift();\n\t\t\t}\n\t\t}\n\t\tyield* buf;\n\t};\n}\n","import type { FS } from '../../fs/fs';\nimport type { Effect } from '../types';\n\nexport interface TouchArgs {\n\tfiles: string[];\n\taccessTimeOnly?: boolean;\n\tmodificationTimeOnly?: boolean;\n}\n\nexport function touch(fs: FS): Effect<TouchArgs> {\n\treturn async ({\n\t\tfiles,\n\t\taccessTimeOnly = false,\n\t\tmodificationTimeOnly = false,\n\t}) => {\n\t\tconst shouldUpdateMtime = !accessTimeOnly || modificationTimeOnly;\n\n\t\tfor (const file of files) {\n\t\t\tif (!(await fs.exists(file))) {\n\t\t\t\tawait fs.writeFile(file, new Uint8Array());\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (shouldUpdateMtime) {\n\t\t\t\tconst content = await fs.readFile(file);\n\t\t\t\tawait fs.writeFile(file, content);\n\t\t\t}\n\t\t}\n\t};\n}\n","import type { FS } from '../fs/fs';\nimport type { Transducer } from '../operator/types';\nimport type { FileRecord, LineRecord } from '../record';\nimport type { Stream } from '../stream';\n\nexport function lines(fs: FS): Transducer<FileRecord, LineRecord> {\n\treturn async function* (input) {\n\t\tfor await (const f of input) {\n\t\t\tlet lineNum = 1;\n\t\t\tfor await (const line of fs.readLines(f.path)) {\n\t\t\t\tyield {\n\t\t\t\t\tfile: f.path,\n\t\t\t\t\tkind: 'line',\n\t\t\t\t\tlineNum: lineNum++,\n\t\t\t\t\ttext: line,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t};\n}\n\nexport async function* files(...paths: string[]): Stream<FileRecord> {\n\tfor (const path of paths) {\n\t\tyield { kind: 'file', path };\n\t}\n}\n","import type {\n\tPipelineIR,\n\tScriptIR,\n\tStatementChainModeIR,\n\tStepIR,\n} from '@shfs/compiler';\nimport { cd } from '../builtin/cd/cd';\nimport { echo } from '../builtin/echo/echo';\nimport { read } from '../builtin/read/read';\nimport { set } from '../builtin/set/set';\nimport { string } from '../builtin/string/string';\nimport { test } from '../builtin/test/test';\nimport type { BuiltinContext, BuiltinRuntime } from '../builtin/types';\nimport type { FS } from '../fs/fs';\nimport { cat } from '../operator/cat/cat';\nimport { cp } from '../operator/cp/cp';\nimport { find } from '../operator/find/find';\nimport { runGrepCommand } from '../operator/grep/grep';\nimport { headLines, headWithN } from '../operator/head/head';\nimport { ls } from '../operator/ls/ls';\nimport { mkdir } from '../operator/mkdir/mkdir';\nimport { mv } from '../operator/mv/mv';\nimport { pwd } from '../operator/pwd/pwd';\nimport { rm } from '../operator/rm/rm';\nimport { tail } from '../operator/tail/tail';\nimport { touch } from '../operator/touch/touch';\nimport type { Record as ShellRecord } from '../record';\nimport type { Stream } from '../stream';\nimport {\n\tevaluateExpandedPathWords,\n\tevaluateExpandedSinglePath,\n\tnormalizeCwd,\n\tresolvePathsFromCwd,\n} from './path';\nimport { files } from './producers';\nimport { toLineStream } from './records';\nimport {\n\tapplyOutputRedirect,\n\thasRedirect,\n\ttype ExecuteResult as RedirectExecuteResult,\n\tresolveRedirectPath,\n\twithInputRedirect,\n} from './redirection';\n\nexport type { ExecuteResult } from './redirection';\n\nexport interface ExecuteContext {\n\tcwd: string;\n\tstatus?: number;\n\tglobalVars?: Map<string, string>;\n\tlocalVars?: Map<string, string>;\n}\n\ntype NormalizedExecuteContext = BuiltinContext;\n\ntype EffectStep = Extract<\n\tStepIR,\n\t{ cmd: 'cd' | 'cp' | 'mkdir' | 'mv' | 'rm' | 'touch' }\n>;\n\ntype StreamStep = Exclude<StepIR, EffectStep>;\n\nconst EFFECT_COMMANDS = new Set(['cd', 'cp', 'mkdir', 'mv', 'rm', 'touch']);\nconst ROOT_DIRECTORY = '/';\nconst TEXT_ENCODER = new TextEncoder();\n\ninterface StreamExecutionOptions {\n\tfinalGrepOutputRedirectPath?: string;\n}\n\nfunction isEffectStep(step: StepIR): step is EffectStep {\n\treturn EFFECT_COMMANDS.has(step.cmd);\n}\n\nasync function* emptyStream<T>(): Stream<T> {\n\t// no records\n}\n\n/**\n * Execute compiles ScriptIR/PipelineIR into an executable result.\n * Returns either a stream (for producers/transducers) or a promise (for sinks).\n */\nexport function execute(\n\tir: PipelineIR | ScriptIR,\n\tfs: FS,\n\tcontext: ExecuteContext = { cwd: ROOT_DIRECTORY }\n): RedirectExecuteResult {\n\tconst normalizedContext = normalizeContext(context);\n\tconst scriptIR = isScriptIR(ir) ? ir : toScriptIR(ir);\n\treturn executeScript(scriptIR, fs, normalizedContext);\n}\n\nfunction isScriptIR(ir: PipelineIR | ScriptIR): ir is ScriptIR {\n\treturn 'statements' in ir;\n}\n\nfunction toScriptIR(pipeline: PipelineIR): ScriptIR {\n\treturn {\n\t\tstatements: [\n\t\t\t{\n\t\t\t\tchainMode: 'always',\n\t\t\t\tpipeline,\n\t\t\t},\n\t\t],\n\t};\n}\n\nfunction isPipelineSink(pipeline: PipelineIR): boolean {\n\tconst finalStep = pipeline.steps.at(-1);\n\tif (!finalStep) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\tisEffectStep(finalStep) || hasRedirect(finalStep.redirections, 'output')\n\t);\n}\n\nfunction shouldExecuteStatement(\n\tchainMode: StatementChainModeIR,\n\tpreviousStatus: number\n): boolean {\n\tif (chainMode === 'always') {\n\t\treturn true;\n\t}\n\tif (chainMode === 'and') {\n\t\treturn previousStatus === 0;\n\t}\n\treturn previousStatus !== 0;\n}\n\nfunction executeScript(\n\tscript: ScriptIR,\n\tfs: FS,\n\tcontext: NormalizedExecuteContext\n): RedirectExecuteResult {\n\tif (script.statements.length === 0) {\n\t\treturn {\n\t\t\tkind: 'stream',\n\t\t\tvalue: emptyStream<ShellRecord>(),\n\t\t};\n\t}\n\n\tif (\n\t\tscript.statements.every((statement) =>\n\t\t\tisPipelineSink(statement.pipeline)\n\t\t)\n\t) {\n\t\treturn {\n\t\t\tkind: 'sink',\n\t\t\tvalue: runScriptToCompletion(script, fs, context),\n\t\t};\n\t}\n\n\treturn {\n\t\tkind: 'stream',\n\t\tvalue: runScriptToStream(script, fs, context),\n\t};\n}\n\nasync function runScriptToCompletion(\n\tscript: ScriptIR,\n\tfs: FS,\n\tcontext: NormalizedExecuteContext\n): Promise<void> {\n\tfor (const statement of script.statements) {\n\t\tif (!shouldExecuteStatement(statement.chainMode, context.status)) {\n\t\t\tcontinue;\n\t\t}\n\t\ttry {\n\t\t\tconst result = executePipeline(statement.pipeline, fs, context);\n\t\t\tawait drainResult(result);\n\t\t} catch (error) {\n\t\t\tcontext.status = 1;\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n\nasync function* runScriptToStream(\n\tscript: ScriptIR,\n\tfs: FS,\n\tcontext: NormalizedExecuteContext\n): Stream<ShellRecord> {\n\tfor (const statement of script.statements) {\n\t\tif (!shouldExecuteStatement(statement.chainMode, context.status)) {\n\t\t\tcontinue;\n\t\t}\n\t\ttry {\n\t\t\tconst result = executePipeline(statement.pipeline, fs, context);\n\t\t\tif (result.kind === 'sink') {\n\t\t\t\tawait result.value;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tyield* result.value;\n\t\t} catch (error) {\n\t\t\tcontext.status = 1;\n\t\t\tthrow error;\n\t\t}\n\t}\n}\n\nasync function drainResult(result: RedirectExecuteResult): Promise<void> {\n\tif (result.kind === 'sink') {\n\t\tawait result.value;\n\t\treturn;\n\t}\n\n\tfor await (const _record of result.value) {\n\t\t// drain stream output to complete side effects.\n\t}\n}\n\nfunction executePipeline(\n\tir: PipelineIR,\n\tfs: FS,\n\tcontext: NormalizedExecuteContext\n): RedirectExecuteResult {\n\tif (ir.steps.length === 0) {\n\t\treturn {\n\t\t\tkind: 'stream',\n\t\t\tvalue: emptyStream<ShellRecord>(),\n\t\t};\n\t}\n\n\tconst lastStep = ir.steps.at(-1);\n\tif (!lastStep) {\n\t\treturn {\n\t\t\tkind: 'stream',\n\t\t\tvalue: emptyStream<ShellRecord>(),\n\t\t};\n\t}\n\n\tif (isEffectStep(lastStep)) {\n\t\tfor (const [index, step] of ir.steps.entries()) {\n\t\t\tif (isEffectStep(step) && index !== ir.steps.length - 1) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Unsupported pipeline: \"${step.cmd}\" must be the final command`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (hasRedirect(lastStep.redirections, 'output')) {\n\t\t\treturn {\n\t\t\t\tkind: 'sink',\n\t\t\t\tvalue: (async () => {\n\t\t\t\t\tconst outputPath = await resolveRedirectPath(\n\t\t\t\t\t\tlastStep.cmd,\n\t\t\t\t\t\tlastStep.redirections,\n\t\t\t\t\t\t'output',\n\t\t\t\t\t\tfs,\n\t\t\t\t\t\tcontext\n\t\t\t\t\t);\n\t\t\t\t\tif (!outputPath) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`${lastStep.cmd}: output redirection missing target`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tawait executePipelineToSink(ir.steps, fs, context);\n\t\t\t\t\tawait fs.writeFile(outputPath, TEXT_ENCODER.encode(''));\n\t\t\t\t})(),\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tkind: 'sink',\n\t\t\tvalue: executePipelineToSink(ir.steps, fs, context),\n\t\t};\n\t}\n\n\tif (\n\t\tlastStep.cmd === 'grep' &&\n\t\thasRedirect(lastStep.redirections, 'output')\n\t) {\n\t\treturn {\n\t\t\tkind: 'sink',\n\t\t\tvalue: (async () => {\n\t\t\t\tconst outputPath = await resolveRedirectPath(\n\t\t\t\t\tlastStep.cmd,\n\t\t\t\t\tlastStep.redirections,\n\t\t\t\t\t'output',\n\t\t\t\t\tfs,\n\t\t\t\t\tcontext\n\t\t\t\t);\n\t\t\t\tif (!outputPath) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`${lastStep.cmd}: output redirection missing target`\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\tconst redirectedResult = applyOutputRedirect(\n\t\t\t\t\t{\n\t\t\t\t\t\tkind: 'stream',\n\t\t\t\t\t\tvalue: executePipelineToStream(ir.steps, fs, context, {\n\t\t\t\t\t\t\tfinalGrepOutputRedirectPath: outputPath,\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t\tlastStep,\n\t\t\t\t\tfs,\n\t\t\t\t\tcontext,\n\t\t\t\t\toutputPath\n\t\t\t\t);\n\t\t\t\tif (redirectedResult.kind !== 'sink') {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`${lastStep.cmd}: output redirection did not produce a sink`\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tawait redirectedResult.value;\n\t\t\t})(),\n\t\t};\n\t}\n\n\tconst stream = executePipelineToStream(ir.steps, fs, context);\n\treturn applyOutputRedirect(\n\t\t{\n\t\t\tkind: 'stream',\n\t\t\tvalue: stream,\n\t\t},\n\t\tlastStep,\n\t\tfs,\n\t\tcontext\n\t);\n}\n\nfunction executePipelineToStream(\n\tsteps: StepIR[],\n\tfs: FS,\n\tcontext: NormalizedExecuteContext,\n\toptions: StreamExecutionOptions = {}\n): Stream<ShellRecord> {\n\treturn (async function* () {\n\t\tlet stream: Stream<ShellRecord> | null = null;\n\t\tfor (const [index, step] of steps.entries()) {\n\t\t\tif (isEffectStep(step)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Unsupported pipeline: \"${step.cmd}\" requires being the final command`\n\t\t\t\t);\n\t\t\t}\n\t\t\tstream = executeStreamStep(\n\t\t\t\tstep,\n\t\t\t\tfs,\n\t\t\t\tstream,\n\t\t\t\tcontext,\n\t\t\t\tindex === steps.length - 1\n\t\t\t\t\t? options.finalGrepOutputRedirectPath\n\t\t\t\t\t: undefined\n\t\t\t);\n\t\t}\n\n\t\tif (!stream) {\n\t\t\treturn;\n\t\t}\n\t\tyield* stream;\n\t})();\n}\n\nasync function executePipelineToSink(\n\tsteps: StepIR[],\n\tfs: FS,\n\tcontext: NormalizedExecuteContext\n): Promise<void> {\n\tconst finalStep = steps.at(-1);\n\tif (!(finalStep && isEffectStep(finalStep))) {\n\t\treturn;\n\t}\n\n\tif (steps.length > 1) {\n\t\tconst stream = executePipelineToStream(steps.slice(0, -1), fs, context);\n\t\tfor await (const _record of stream) {\n\t\t\t// drain\n\t\t}\n\t}\n\n\tawait executeEffectStep(finalStep, fs, context);\n}\n\nfunction executeStreamStep(\n\tstep: StreamStep,\n\tfs: FS,\n\tinput: Stream<ShellRecord> | null,\n\tcontext: NormalizedExecuteContext,\n\tresolvedOutputRedirectPath?: string\n): Stream<ShellRecord> {\n\tconst builtinRuntime = createBuiltinRuntime(fs, context, input);\n\n\tswitch (step.cmd) {\n\t\tcase 'cat': {\n\t\t\treturn (async function* (): Stream<ShellRecord> {\n\t\t\t\tconst options = {\n\t\t\t\t\tnumberLines: step.args.numberLines,\n\t\t\t\t\tnumberNonBlank: step.args.numberNonBlank,\n\t\t\t\t\tshowAll: step.args.showAll,\n\t\t\t\t\tshowEnds: step.args.showEnds,\n\t\t\t\t\tshowNonprinting: step.args.showNonprinting,\n\t\t\t\t\tshowTabs: step.args.showTabs,\n\t\t\t\t\tsqueezeBlank: step.args.squeezeBlank,\n\t\t\t\t};\n\t\t\t\tconst inputPath = await resolveRedirectPath(\n\t\t\t\t\tstep.cmd,\n\t\t\t\t\tstep.redirections,\n\t\t\t\t\t'input',\n\t\t\t\t\tfs,\n\t\t\t\t\tcontext\n\t\t\t\t);\n\t\t\t\tconst filePaths = withInputRedirect(\n\t\t\t\t\tresolvePathsFromCwd(\n\t\t\t\t\t\tcontext.cwd,\n\t\t\t\t\t\tawait evaluateExpandedPathWords(\n\t\t\t\t\t\t\t'cat',\n\t\t\t\t\t\t\tstep.args.files,\n\t\t\t\t\t\t\tfs,\n\t\t\t\t\t\t\tcontext\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\tinputPath\n\t\t\t\t);\n\t\t\t\tif (filePaths.length > 0) {\n\t\t\t\t\tyield* cat(fs, options)(files(...filePaths));\n\t\t\t\t\tcontext.status = 0;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (input) {\n\t\t\t\t\tyield* cat(fs, options)(input);\n\t\t\t\t}\n\t\t\t\tcontext.status = 0;\n\t\t\t})();\n\t\t}\n\t\tcase 'grep': {\n\t\t\treturn (async function* (): Stream<ShellRecord> {\n\t\t\t\tconst result = await runGrepCommand({\n\t\t\t\t\tcontext,\n\t\t\t\t\tfs,\n\t\t\t\t\tinput,\n\t\t\t\t\t// @shfs/compiler can be consumed as a built package in this workspace,\n\t\t\t\t\t// so grep args may type as legacy argv until compiler is rebuilt.\n\t\t\t\t\tparsed: step.args as unknown as Parameters<\n\t\t\t\t\t\ttypeof runGrepCommand\n\t\t\t\t\t>[0]['parsed'],\n\t\t\t\t\tredirections: step.redirections,\n\t\t\t\t\tresolvedOutputRedirectPath,\n\t\t\t\t});\n\t\t\t\tcontext.status = result.status;\n\t\t\t\tfor (const text of result.lines) {\n\t\t\t\t\tyield {\n\t\t\t\t\t\tkind: 'line',\n\t\t\t\t\t\ttext,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t})();\n\t\t}\n\t\tcase 'find': {\n\t\t\treturn find(fs, context, step.args);\n\t\t}\n\t\tcase 'head': {\n\t\t\treturn (async function* (): Stream<ShellRecord> {\n\t\t\t\tconst inputPath = await resolveRedirectPath(\n\t\t\t\t\tstep.cmd,\n\t\t\t\t\tstep.redirections,\n\t\t\t\t\t'input',\n\t\t\t\t\tfs,\n\t\t\t\t\tcontext\n\t\t\t\t);\n\t\t\t\tconst filePaths = withInputRedirect(\n\t\t\t\t\tresolvePathsFromCwd(\n\t\t\t\t\t\tcontext.cwd,\n\t\t\t\t\t\tawait evaluateExpandedPathWords(\n\t\t\t\t\t\t\t'head',\n\t\t\t\t\t\t\tstep.args.files,\n\t\t\t\t\t\t\tfs,\n\t\t\t\t\t\t\tcontext\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\tinputPath\n\t\t\t\t);\n\t\t\t\tif (filePaths.length > 0) {\n\t\t\t\t\tyield* headWithN(fs, step.args.n)(files(...filePaths));\n\t\t\t\t\tcontext.status = 0;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (input) {\n\t\t\t\t\tyield* headLines(step.args.n)(toLineStream(fs, input));\n\t\t\t\t}\n\t\t\t\tcontext.status = 0;\n\t\t\t})();\n\t\t}\n\t\tcase 'ls': {\n\t\t\treturn (async function* (): Stream<ShellRecord> {\n\t\t\t\tconst paths = await evaluateExpandedPathWords(\n\t\t\t\t\t'ls',\n\t\t\t\t\tstep.args.paths,\n\t\t\t\t\tfs,\n\t\t\t\t\tcontext\n\t\t\t\t);\n\t\t\t\tfor (const inputPath of paths) {\n\t\t\t\t\tconst resolvedPath = resolveLsPath(inputPath, context.cwd);\n\t\t\t\t\tfor await (const fileRecord of ls(fs, resolvedPath, {\n\t\t\t\t\t\tshowAll: step.args.showAll,\n\t\t\t\t\t})) {\n\t\t\t\t\t\tif (step.args.longFormat) {\n\t\t\t\t\t\t\tconst stat = await fs.stat(fileRecord.path);\n\t\t\t\t\t\t\tyield {\n\t\t\t\t\t\t\t\tkind: 'line',\n\t\t\t\t\t\t\t\ttext: formatLongListing(fileRecord.path, stat),\n\t\t\t\t\t\t\t} as const;\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tyield fileRecord;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontext.status = 0;\n\t\t\t})();\n\t\t}\n\t\tcase 'tail': {\n\t\t\treturn (async function* (): Stream<ShellRecord> {\n\t\t\t\tconst inputPath = await resolveRedirectPath(\n\t\t\t\t\tstep.cmd,\n\t\t\t\t\tstep.redirections,\n\t\t\t\t\t'input',\n\t\t\t\t\tfs,\n\t\t\t\t\tcontext\n\t\t\t\t);\n\t\t\t\tconst filePaths = withInputRedirect(\n\t\t\t\t\tresolvePathsFromCwd(\n\t\t\t\t\t\tcontext.cwd,\n\t\t\t\t\t\tawait evaluateExpandedPathWords(\n\t\t\t\t\t\t\t'tail',\n\t\t\t\t\t\t\tstep.args.files,\n\t\t\t\t\t\t\tfs,\n\t\t\t\t\t\t\tcontext\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\tinputPath\n\t\t\t\t);\n\t\t\t\tif (filePaths.length > 0) {\n\t\t\t\t\tfor (const filePath of filePaths) {\n\t\t\t\t\t\tyield* tail(step.args.n)(cat(fs)(files(filePath)));\n\t\t\t\t\t}\n\t\t\t\t\tcontext.status = 0;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (input) {\n\t\t\t\t\tyield* tail(step.args.n)(toLineStream(fs, input));\n\t\t\t\t}\n\t\t\t\tcontext.status = 0;\n\t\t\t})();\n\t\t}\n\t\tcase 'pwd': {\n\t\t\treturn (async function* (): Stream<ShellRecord> {\n\t\t\t\tyield* pwd(context.cwd);\n\t\t\t\tcontext.status = 0;\n\t\t\t})();\n\t\t}\n\t\tcase 'echo': {\n\t\t\treturn echo(builtinRuntime, step.args);\n\t\t}\n\t\tcase 'set': {\n\t\t\treturn set(builtinRuntime, step.args);\n\t\t}\n\t\tcase 'test': {\n\t\t\treturn test(builtinRuntime, step.args);\n\t\t}\n\t\tcase 'read': {\n\t\t\treturn read(builtinRuntime, step.args);\n\t\t}\n\t\tcase 'string': {\n\t\t\treturn string(builtinRuntime, step.args);\n\t\t}\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = step;\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown command: ${String((_exhaustive as { cmd: string }).cmd)}`\n\t\t\t);\n\t\t}\n\t}\n}\n\nasync function executeEffectStep(\n\tstep: EffectStep,\n\tfs: FS,\n\tcontext: NormalizedExecuteContext\n): Promise<void> {\n\tconst builtinRuntime = createBuiltinRuntime(fs, context, null);\n\n\tswitch (step.cmd) {\n\t\tcase 'cd': {\n\t\t\tawait cd(builtinRuntime, step.args);\n\t\t\tbreak;\n\t\t}\n\t\tcase 'cp': {\n\t\t\tconst srcPaths = resolvePathsFromCwd(\n\t\t\t\tcontext.cwd,\n\t\t\t\tawait evaluateExpandedPathWords(\n\t\t\t\t\t'cp',\n\t\t\t\t\tstep.args.srcs,\n\t\t\t\t\tfs,\n\t\t\t\t\tcontext\n\t\t\t\t)\n\t\t\t);\n\t\t\tconst destinationPaths = resolvePathsFromCwd(context.cwd, [\n\t\t\t\tawait evaluateExpandedSinglePath(\n\t\t\t\t\t'cp',\n\t\t\t\t\t'destination must expand to exactly 1 path',\n\t\t\t\t\tstep.args.dest,\n\t\t\t\t\tfs,\n\t\t\t\t\tcontext\n\t\t\t\t),\n\t\t\t]);\n\t\t\tconst destinationPath = destinationPaths.at(0);\n\t\t\tif (destinationPath === undefined) {\n\t\t\t\tthrow new Error('cp: destination missing after expansion');\n\t\t\t}\n\t\t\tawait cp(fs)({\n\t\t\t\tsrcs: srcPaths,\n\t\t\t\tdest: destinationPath,\n\t\t\t\tforce: step.args.force,\n\t\t\t\tinteractive: step.args.interactive,\n\t\t\t\trecursive: step.args.recursive,\n\t\t\t});\n\t\t\tcontext.status = 0;\n\t\t\tbreak;\n\t\t}\n\t\tcase 'mkdir': {\n\t\t\tconst paths = resolvePathsFromCwd(\n\t\t\t\tcontext.cwd,\n\t\t\t\tawait evaluateExpandedPathWords(\n\t\t\t\t\t'mkdir',\n\t\t\t\t\tstep.args.paths,\n\t\t\t\t\tfs,\n\t\t\t\t\tcontext\n\t\t\t\t)\n\t\t\t);\n\t\t\tfor (const path of paths) {\n\t\t\t\tawait mkdir(fs)({ path, recursive: step.args.recursive });\n\t\t\t}\n\t\t\tcontext.status = 0;\n\t\t\tbreak;\n\t\t}\n\t\tcase 'mv': {\n\t\t\tconst srcPaths = resolvePathsFromCwd(\n\t\t\t\tcontext.cwd,\n\t\t\t\tawait evaluateExpandedPathWords(\n\t\t\t\t\t'mv',\n\t\t\t\t\tstep.args.srcs,\n\t\t\t\t\tfs,\n\t\t\t\t\tcontext\n\t\t\t\t)\n\t\t\t);\n\t\t\tconst destinationPaths = resolvePathsFromCwd(context.cwd, [\n\t\t\t\tawait evaluateExpandedSinglePath(\n\t\t\t\t\t'mv',\n\t\t\t\t\t'destination must expand to exactly 1 path',\n\t\t\t\t\tstep.args.dest,\n\t\t\t\t\tfs,\n\t\t\t\t\tcontext\n\t\t\t\t),\n\t\t\t]);\n\t\t\tconst destinationPath = destinationPaths.at(0);\n\t\t\tif (destinationPath === undefined) {\n\t\t\t\tthrow new Error('mv: destination missing after expansion');\n\t\t\t}\n\t\t\tawait mv(fs)({\n\t\t\t\tsrcs: srcPaths,\n\t\t\t\tdest: destinationPath,\n\t\t\t\tforce: step.args.force,\n\t\t\t\tinteractive: step.args.interactive,\n\t\t\t});\n\t\t\tcontext.status = 0;\n\t\t\tbreak;\n\t\t}\n\t\tcase 'rm': {\n\t\t\tconst paths = resolvePathsFromCwd(\n\t\t\t\tcontext.cwd,\n\t\t\t\tawait evaluateExpandedPathWords(\n\t\t\t\t\t'rm',\n\t\t\t\t\tstep.args.paths,\n\t\t\t\t\tfs,\n\t\t\t\t\tcontext\n\t\t\t\t)\n\t\t\t);\n\t\t\tfor (const path of paths) {\n\t\t\t\tawait rm(fs)({\n\t\t\t\t\tpath,\n\t\t\t\t\tforce: step.args.force,\n\t\t\t\t\tinteractive: step.args.interactive,\n\t\t\t\t\trecursive: step.args.recursive,\n\t\t\t\t});\n\t\t\t}\n\t\t\tcontext.status = 0;\n\t\t\tbreak;\n\t\t}\n\t\tcase 'touch': {\n\t\t\tconst filePaths = resolvePathsFromCwd(\n\t\t\t\tcontext.cwd,\n\t\t\t\tawait evaluateExpandedPathWords(\n\t\t\t\t\t'touch',\n\t\t\t\t\tstep.args.files,\n\t\t\t\t\tfs,\n\t\t\t\t\tcontext\n\t\t\t\t)\n\t\t\t);\n\t\t\tawait touch(fs)({\n\t\t\t\tfiles: filePaths,\n\t\t\t\taccessTimeOnly: step.args.accessTimeOnly,\n\t\t\t\tmodificationTimeOnly: step.args.modificationTimeOnly,\n\t\t\t});\n\t\t\tcontext.status = 0;\n\t\t\tbreak;\n\t\t}\n\t\tdefault: {\n\t\t\tconst _exhaustive: never = step;\n\t\t\tthrow new Error(\n\t\t\t\t`Unknown command: ${String((_exhaustive as { cmd: string }).cmd)}`\n\t\t\t);\n\t\t}\n\t}\n}\n\nfunction createBuiltinRuntime(\n\tfs: FS,\n\tcontext: NormalizedExecuteContext,\n\tinput: Stream<ShellRecord> | null\n): BuiltinRuntime {\n\treturn {\n\t\tfs,\n\t\tcontext,\n\t\tinput,\n\t};\n}\n\nfunction formatLongListing(\n\tpath: string,\n\tstat: Awaited<ReturnType<FS['stat']>>\n): string {\n\tconst mode = stat.isDirectory ? 'd' : '-';\n\tconst size = String(stat.size).padStart(8, ' ');\n\treturn `${mode} ${size} ${stat.mtime.toISOString()} ${path}`;\n}\n\nfunction normalizeLsPath(path: string, cwd: string): string {\n\tif (path === '.' || path === './') {\n\t\treturn cwd;\n\t}\n\tif (path.startsWith('./')) {\n\t\treturn `${cwd}/${path.slice(2)}`;\n\t}\n\tif (path.startsWith(ROOT_DIRECTORY)) {\n\t\treturn path;\n\t}\n\treturn `${cwd}/${path}`;\n}\n\nfunction resolveLsPath(path: string, cwd: string): string {\n\treturn normalizeLsPath(path, cwd);\n}\n\nfunction normalizeContext(context: ExecuteContext): NormalizedExecuteContext {\n\tcontext.cwd = normalizeCwd(context.cwd);\n\tcontext.status ??= 0;\n\tcontext.globalVars ??= new Map<string, string>();\n\tcontext.localVars ??= new Map<string, string>();\n\treturn context as NormalizedExecuteContext;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,SAAS,QAAQ,OAAO;AACvB,QAAO;EACN,MAAM;EACN;EACA;;;;;AAKF,SAAS,SAAS,OAAO;AACxB,QAAO;EACN,MAAM;EACN;EACA;;;;;AAgBF,SAAS,KAAK,SAAS,WAAW,EAAE,EAAE;AACrC,QAAO;EACN,MAAM;EACN;EACA;EACA;;;;;AAKF,SAAS,WAAW,SAAS,SAAS,EAAE,EAAE;AACzC,QAAO;EACN,MAAM;EACN;EACA;EACA;;;;;;AAMF,SAAS,qBAAqB,MAAM;AACnC,SAAQ,KAAK,MAAb;EACC,KAAK,UAAW,QAAO,KAAK;EAC5B,KAAK,OAAQ,QAAO,KAAK;EACzB,KAAK,aAAc,QAAO,KAAK;EAC/B,KAAK,WAAY,QAAO,KA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