just-bash 2.5.5 → 2.6.0
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.
- package/README.md +2 -2
- package/dist/AGENTS.md +2 -2
- package/dist/ast/types.d.ts +100 -11
- package/dist/bin/chunks/alias-EGIS5LUE.js +7 -0
- package/dist/bin/chunks/awk2-GFEJOWML.js +21 -0
- package/dist/bin/chunks/bash-PGDTHIM2.js +6 -0
- package/dist/bin/chunks/chmod-TYLTHXFR.js +9 -0
- package/dist/bin/chunks/chunk-D5WP4CKS.js +3 -0
- package/dist/bin/chunks/chunk-FSAGDARS.js +74 -0
- package/dist/bin/chunks/chunk-FSZWFMB4.js +16 -0
- package/dist/bin/chunks/chunk-IRUD2E3M.js +17 -0
- package/dist/bin/chunks/chunk-K5IXNHO5.js +8 -0
- package/dist/bin/chunks/chunk-KD3EODLB.js +6 -0
- package/dist/bin/{shell/chunks/echo-WSKTON6U.js → chunks/echo-7I42V66Q.js} +2 -2
- package/dist/bin/chunks/env-7A4MH7BJ.js +9 -0
- package/dist/bin/chunks/expansion-BOR3ELLC.js +2 -0
- package/dist/bin/{shell/chunks/find-CBEJ35BR.js → chunks/find-PHDZK64M.js} +1 -1
- package/dist/bin/{shell/chunks/grep-IIVQXFNI.js → chunks/grep-VX7MJMVN.js} +2 -2
- package/dist/bin/chunks/{head-DYK37Z24.js → head-TJHLLIMR.js} +1 -1
- package/dist/bin/{shell/chunks/jq-XXZPU5CA.js → chunks/jq-RGZHJNXC.js} +1 -1
- package/dist/bin/chunks/od-KRKGC2U3.js +5 -0
- package/dist/bin/chunks/printf-YPXD4CRE.js +15 -0
- package/dist/bin/chunks/pwd-L26WH2K4.js +3 -0
- package/dist/bin/{shell/chunks/rg-Q4OTJOEF.js → chunks/rg-RSDLLECO.js} +1 -1
- package/dist/bin/chunks/rmdir-GOODLY5W.js +14 -0
- package/dist/bin/chunks/sed-JPDTWF4W.js +100 -0
- package/dist/bin/{shell/chunks/tail-BES27CZT.js → chunks/tail-YAUIERGN.js} +1 -1
- package/dist/bin/{shell/chunks/tar-C27YYUAS.js → chunks/tar-LFENC54A.js} +7 -7
- package/dist/bin/chunks/time-37F5EBPK.js +14 -0
- package/dist/bin/chunks/touch-IBPHJBM3.js +7 -0
- package/dist/bin/chunks/wc-SAOHEZYP.js +6 -0
- package/dist/bin/chunks/{which-73KOOLC6.js → which-FCDFBOMN.js} +1 -1
- package/dist/bin/chunks/whoami-JVLUNKSG.js +3 -0
- package/dist/bin/{shell/chunks/xan-6K2NGTHM.js → chunks/xan-5HNHTFMB.js} +19 -19
- package/dist/bin/chunks/{yq-MF2SNFGL.js → yq-PFV4T2PV.js} +1 -1
- package/dist/bin/just-bash.js +659 -135
- package/dist/bin/shell/chunks/alias-EGIS5LUE.js +7 -0
- package/dist/bin/shell/chunks/awk2-GFEJOWML.js +21 -0
- package/dist/bin/shell/chunks/bash-PGDTHIM2.js +6 -0
- package/dist/bin/shell/chunks/chmod-TYLTHXFR.js +9 -0
- package/dist/bin/shell/chunks/chunk-D5WP4CKS.js +3 -0
- package/dist/bin/shell/chunks/chunk-FSAGDARS.js +74 -0
- package/dist/bin/shell/chunks/chunk-FSZWFMB4.js +16 -0
- package/dist/bin/shell/chunks/chunk-IRUD2E3M.js +17 -0
- package/dist/bin/shell/chunks/chunk-K5IXNHO5.js +8 -0
- package/dist/bin/shell/chunks/chunk-KD3EODLB.js +6 -0
- package/dist/bin/{chunks/echo-WSKTON6U.js → shell/chunks/echo-7I42V66Q.js} +2 -2
- package/dist/bin/shell/chunks/env-7A4MH7BJ.js +9 -0
- package/dist/bin/shell/chunks/expansion-BOR3ELLC.js +2 -0
- package/dist/bin/{chunks/find-CBEJ35BR.js → shell/chunks/find-PHDZK64M.js} +1 -1
- package/dist/bin/{chunks/grep-IIVQXFNI.js → shell/chunks/grep-VX7MJMVN.js} +2 -2
- package/dist/bin/shell/chunks/{head-DYK37Z24.js → head-TJHLLIMR.js} +1 -1
- package/dist/bin/{chunks/jq-XXZPU5CA.js → shell/chunks/jq-RGZHJNXC.js} +1 -1
- package/dist/bin/shell/chunks/od-KRKGC2U3.js +5 -0
- package/dist/bin/shell/chunks/printf-YPXD4CRE.js +15 -0
- package/dist/bin/shell/chunks/pwd-L26WH2K4.js +3 -0
- package/dist/bin/{chunks/rg-Q4OTJOEF.js → shell/chunks/rg-RSDLLECO.js} +1 -1
- package/dist/bin/shell/chunks/rmdir-GOODLY5W.js +14 -0
- package/dist/bin/shell/chunks/sed-JPDTWF4W.js +100 -0
- package/dist/bin/{chunks/tail-BES27CZT.js → shell/chunks/tail-YAUIERGN.js} +1 -1
- package/dist/bin/{chunks/tar-C27YYUAS.js → shell/chunks/tar-LFENC54A.js} +7 -7
- package/dist/bin/shell/chunks/time-37F5EBPK.js +14 -0
- package/dist/bin/shell/chunks/touch-IBPHJBM3.js +7 -0
- package/dist/bin/shell/chunks/wc-SAOHEZYP.js +6 -0
- package/dist/bin/shell/chunks/{which-73KOOLC6.js → which-FCDFBOMN.js} +1 -1
- package/dist/bin/shell/chunks/whoami-JVLUNKSG.js +3 -0
- package/dist/bin/{chunks/xan-6K2NGTHM.js → shell/chunks/xan-5HNHTFMB.js} +19 -19
- package/dist/bin/shell/chunks/{yq-MF2SNFGL.js → yq-PFV4T2PV.js} +1 -1
- package/dist/bin/shell/shell.js +664 -140
- package/dist/bundle/browser.js +1251 -606
- package/dist/bundle/chunks/alias-ATFBB6D2.js +6 -0
- package/dist/bundle/chunks/awk2-6FBZTP57.js +20 -0
- package/dist/bundle/chunks/bash-OLRNM52U.js +5 -0
- package/dist/bundle/chunks/chmod-ODWUR7E6.js +8 -0
- package/dist/bundle/chunks/chunk-3AWP5CWK.js +73 -0
- package/dist/bundle/chunks/chunk-CXEWLFNE.js +16 -0
- package/dist/bundle/chunks/chunk-CZPA5RBA.js +5 -0
- package/dist/bundle/chunks/chunk-EEXR5ZDP.js +2 -0
- package/dist/bundle/chunks/chunk-HDQ56CKY.js +15 -0
- package/dist/bundle/chunks/chunk-PSW6BMXW.js +7 -0
- package/dist/bundle/chunks/{echo-VUHWYV6L.js → echo-6S7WE7XB.js} +2 -2
- package/dist/bundle/chunks/env-2UI6XINU.js +8 -0
- package/dist/bundle/chunks/expansion-RIGCFEMA.js +1 -0
- package/dist/bundle/chunks/{find-ACOAWALE.js → find-YGMSVGUV.js} +1 -1
- package/dist/bundle/chunks/{grep-ACVE42JK.js → grep-NIC6JNLH.js} +2 -2
- package/dist/bundle/chunks/{head-FZ6IQHYW.js → head-SA7P5NJ7.js} +1 -1
- package/dist/bundle/chunks/{jq-3YU5HRKE.js → jq-RLRYRPOJ.js} +1 -1
- package/dist/bundle/chunks/od-3FPDPLWJ.js +4 -0
- package/dist/bundle/chunks/printf-66XGXFCD.js +14 -0
- package/dist/bundle/chunks/pwd-S4NVAMC4.js +2 -0
- package/dist/bundle/chunks/{rg-YLZJWCEJ.js → rg-SRMB7L6G.js} +1 -1
- package/dist/bundle/chunks/rmdir-XFQE4ZYV.js +13 -0
- package/dist/bundle/chunks/sed-IV6HLDXU.js +99 -0
- package/dist/bundle/chunks/{tail-PD4RZR6J.js → tail-52LRAWXT.js} +1 -1
- package/dist/bundle/chunks/{tar-QWBXMF7K.js → tar-LWIHPMT6.js} +7 -7
- package/dist/bundle/chunks/time-UWXBG6CS.js +13 -0
- package/dist/bundle/chunks/touch-TDTEBHHI.js +6 -0
- package/dist/bundle/chunks/wc-HE5XARI4.js +5 -0
- package/dist/bundle/chunks/{which-M5MQ6QXQ.js → which-UBLRBDHN.js} +1 -1
- package/dist/bundle/chunks/whoami-YUDAIS32.js +2 -0
- package/dist/bundle/chunks/{xan-2R2APJJ4.js → xan-A6VPI4HJ.js} +19 -19
- package/dist/bundle/chunks/{yq-KANM4MD2.js → yq-L665QPQU.js} +1 -1
- package/dist/bundle/index.js +657 -133
- package/dist/commands/awk/ast.d.ts +1 -0
- package/dist/commands/awk/interpreter/context.d.ts +14 -0
- package/dist/commands/awk/interpreter/interpreter.d.ts +2 -0
- package/dist/commands/awk/interpreter/{helpers.d.ts → type-coercion.d.ts} +4 -1
- package/dist/commands/awk/parser2-print.d.ts +35 -0
- package/dist/commands/awk/parser2.d.ts +42 -34
- package/dist/commands/printf/strftime.d.ts +9 -0
- package/dist/commands/query-engine/builtins/array-builtins.d.ts +20 -0
- package/dist/commands/query-engine/builtins/control-builtins.d.ts +18 -0
- package/dist/commands/query-engine/builtins/date-builtins.d.ts +15 -0
- package/dist/commands/query-engine/builtins/format-builtins.d.ts +11 -0
- package/dist/commands/query-engine/builtins/index-builtins.d.ts +16 -0
- package/dist/commands/query-engine/builtins/index.d.ts +17 -0
- package/dist/commands/query-engine/builtins/math-builtins.d.ts +15 -0
- package/dist/commands/query-engine/builtins/navigation-builtins.d.ts +18 -0
- package/dist/commands/query-engine/builtins/object-builtins.d.ts +15 -0
- package/dist/commands/query-engine/builtins/path-builtins.d.ts +20 -0
- package/dist/commands/query-engine/builtins/sql-builtins.d.ts +16 -0
- package/dist/commands/query-engine/builtins/string-builtins.d.ts +15 -0
- package/dist/commands/query-engine/builtins/type-builtins.d.ts +11 -0
- package/dist/commands/query-engine/evaluator.d.ts +10 -2
- package/dist/commands/query-engine/parser-types.d.ts +171 -0
- package/dist/commands/query-engine/parser.d.ts +2 -132
- package/dist/commands/query-engine/path-operations.d.ts +15 -0
- package/dist/commands/query-engine/value-operations.d.ts +39 -0
- package/dist/commands/registry.d.ts +1 -1
- package/dist/commands/rmdir/rmdir.d.ts +2 -0
- package/dist/commands/sed/lexer.d.ts +12 -0
- package/dist/commands/sed/parser.d.ts +9 -0
- package/dist/commands/sed/sed-regex.d.ts +23 -0
- package/dist/commands/sed/types.d.ts +13 -1
- package/dist/commands/tar/tar-options.d.ts +36 -0
- package/dist/commands/time/time.d.ts +25 -0
- package/dist/commands/whoami/whoami.d.ts +9 -0
- package/dist/commands/xan/moonblade-tokenizer.d.ts +25 -0
- package/dist/fs/in-memory-fs/in-memory-fs.d.ts +12 -0
- package/dist/fs/interface.d.ts +16 -0
- package/dist/fs/mountable-fs/mountable-fs.d.ts +12 -0
- package/dist/fs/overlay-fs/overlay-fs.d.ts +13 -1
- package/dist/fs/read-write-fs/read-write-fs.d.ts +13 -1
- package/dist/interpreter/alias-expansion.d.ts +23 -0
- package/dist/interpreter/arithmetic.d.ts +1 -6
- package/dist/interpreter/assignment-expansion.d.ts +24 -0
- package/dist/interpreter/builtin-dispatch.d.ts +39 -0
- package/dist/interpreter/builtins/compgen.d.ts +26 -0
- package/dist/interpreter/builtins/complete.d.ts +17 -0
- package/dist/interpreter/builtins/compopt.d.ts +28 -0
- package/dist/interpreter/builtins/declare-array-parsing.d.ts +14 -0
- package/dist/interpreter/builtins/declare-print.d.ts +39 -0
- package/dist/interpreter/builtins/declare.d.ts +10 -4
- package/dist/interpreter/builtins/dirs.d.ts +29 -0
- package/dist/interpreter/builtins/eval.d.ts +1 -1
- package/dist/interpreter/builtins/export.d.ts +1 -0
- package/dist/interpreter/builtins/getopts.d.ts +18 -0
- package/dist/interpreter/builtins/hash.d.ts +19 -0
- package/dist/interpreter/builtins/help.d.ts +12 -0
- package/dist/interpreter/builtins/index.d.ts +9 -1
- package/dist/interpreter/builtins/local.d.ts +1 -1
- package/dist/interpreter/builtins/read.d.ts +1 -1
- package/dist/interpreter/builtins/set.d.ts +3 -0
- package/dist/interpreter/builtins/shift.d.ts +3 -0
- package/dist/interpreter/builtins/shopt.d.ts +7 -0
- package/dist/interpreter/builtins/unset.d.ts +5 -1
- package/dist/interpreter/builtins/variable-assignment.d.ts +66 -0
- package/dist/interpreter/command-resolution.d.ts +43 -0
- package/dist/interpreter/conditionals.d.ts +1 -1
- package/dist/interpreter/errors.d.ts +36 -1
- package/dist/interpreter/expansion/analysis.d.ts +15 -17
- package/dist/interpreter/expansion/arith-text-expansion.d.ts +20 -0
- package/dist/interpreter/expansion/array-pattern-ops.d.ts +21 -0
- package/dist/interpreter/expansion/array-prefix-suffix.d.ts +46 -0
- package/dist/interpreter/expansion/array-slice-transform.d.ts +36 -0
- package/dist/interpreter/expansion/array-word-expansion.d.ts +39 -0
- package/dist/interpreter/expansion/command-substitution.d.ts +23 -0
- package/dist/interpreter/expansion/glob-escape.d.ts +32 -0
- package/dist/interpreter/expansion/indirect-expansion.d.ts +42 -0
- package/dist/interpreter/expansion/parameter-ops.d.ts +113 -0
- package/dist/interpreter/expansion/pattern-expansion.d.ts +23 -0
- package/dist/interpreter/expansion/pattern-removal.d.ts +18 -0
- package/dist/interpreter/expansion/pattern.d.ts +2 -1
- package/dist/interpreter/expansion/positional-params.d.ts +59 -0
- package/dist/interpreter/expansion/prompt.d.ts +39 -0
- package/dist/interpreter/expansion/quoting.d.ts +13 -0
- package/dist/interpreter/expansion/tilde.d.ts +12 -0
- package/dist/interpreter/expansion/unquoted-expansion.d.ts +76 -0
- package/dist/interpreter/expansion/variable-attrs.d.ts +19 -0
- package/dist/interpreter/expansion/variable.d.ts +10 -1
- package/dist/interpreter/expansion/word-glob-expansion.d.ts +33 -0
- package/dist/interpreter/expansion/word-split.d.ts +11 -6
- package/dist/interpreter/expansion.d.ts +30 -4
- package/dist/interpreter/functions.d.ts +1 -1
- package/dist/interpreter/helpers/array.d.ts +20 -0
- package/dist/interpreter/helpers/ifs.d.ts +66 -5
- package/dist/interpreter/helpers/nameref.d.ts +65 -0
- package/dist/interpreter/helpers/quoting.d.ts +24 -0
- package/dist/interpreter/helpers/readonly.d.ts +28 -4
- package/dist/interpreter/helpers/shell-constants.d.ts +25 -0
- package/dist/interpreter/helpers/shellopts.d.ts +28 -0
- package/dist/interpreter/helpers/string-compare.d.ts +3 -1
- package/dist/interpreter/helpers/tilde.d.ts +13 -0
- package/dist/interpreter/helpers/variable-tests.d.ts +1 -1
- package/dist/interpreter/helpers/word-matching.d.ts +26 -0
- package/dist/interpreter/helpers/xtrace.d.ts +18 -0
- package/dist/interpreter/interpreter.d.ts +13 -14
- package/dist/interpreter/pipeline-execution.d.ts +16 -0
- package/dist/interpreter/redirections.d.ts +38 -1
- package/dist/interpreter/simple-command-assignments.d.ts +29 -0
- package/dist/interpreter/subshell-group.d.ts +32 -0
- package/dist/interpreter/type-command.d.ts +37 -0
- package/dist/interpreter/types.d.ts +255 -21
- package/dist/parser/arithmetic-parser.d.ts +2 -4
- package/dist/parser/arithmetic-primaries.d.ts +45 -0
- package/dist/parser/compound-parser.d.ts +21 -7
- package/dist/parser/expansion-parser.d.ts +7 -1
- package/dist/parser/lexer.d.ts +57 -0
- package/dist/parser/parser-substitution.d.ts +62 -0
- package/dist/parser/parser.d.ts +39 -2
- package/dist/parser/types.d.ts +1 -0
- package/dist/types.d.ts +17 -0
- package/package.json +4 -1
- package/dist/bin/chunks/alias-PCMLRCRW.js +0 -7
- package/dist/bin/chunks/awk2-D2US2LMM.js +0 -20
- package/dist/bin/chunks/bash-UT3MT5UU.js +0 -7
- package/dist/bin/chunks/chmod-3DIKREF7.js +0 -9
- package/dist/bin/chunks/chunk-ACRTDIBO.js +0 -6
- package/dist/bin/chunks/chunk-DV5HL4K2.js +0 -17
- package/dist/bin/chunks/chunk-J7BCMQDI.js +0 -16
- package/dist/bin/chunks/chunk-NWWB2XRE.js +0 -6
- package/dist/bin/chunks/chunk-PM2DS2YW.js +0 -3
- package/dist/bin/chunks/env-YLLSNZZN.js +0 -9
- package/dist/bin/chunks/od-SLM7SRWU.js +0 -7
- package/dist/bin/chunks/printf-HWUQKYUM.js +0 -14
- package/dist/bin/chunks/pwd-53KG2MCJ.js +0 -3
- package/dist/bin/chunks/sed-5LQMJYRJ.js +0 -80
- package/dist/bin/chunks/touch-TSNAXMZ2.js +0 -4
- package/dist/bin/chunks/wc-QSBRKIF5.js +0 -6
- package/dist/bin/shell/chunks/alias-PCMLRCRW.js +0 -7
- package/dist/bin/shell/chunks/awk2-D2US2LMM.js +0 -20
- package/dist/bin/shell/chunks/bash-UT3MT5UU.js +0 -7
- package/dist/bin/shell/chunks/chmod-3DIKREF7.js +0 -9
- package/dist/bin/shell/chunks/chunk-ACRTDIBO.js +0 -6
- package/dist/bin/shell/chunks/chunk-DV5HL4K2.js +0 -17
- package/dist/bin/shell/chunks/chunk-J7BCMQDI.js +0 -16
- package/dist/bin/shell/chunks/chunk-NWWB2XRE.js +0 -6
- package/dist/bin/shell/chunks/chunk-PM2DS2YW.js +0 -3
- package/dist/bin/shell/chunks/env-YLLSNZZN.js +0 -9
- package/dist/bin/shell/chunks/od-SLM7SRWU.js +0 -7
- package/dist/bin/shell/chunks/printf-HWUQKYUM.js +0 -14
- package/dist/bin/shell/chunks/pwd-53KG2MCJ.js +0 -3
- package/dist/bin/shell/chunks/sed-5LQMJYRJ.js +0 -80
- package/dist/bin/shell/chunks/touch-TSNAXMZ2.js +0 -4
- package/dist/bin/shell/chunks/wc-QSBRKIF5.js +0 -6
- package/dist/bundle/chunks/alias-4UGRF4DM.js +0 -6
- package/dist/bundle/chunks/awk2-46RTIZKB.js +0 -19
- package/dist/bundle/chunks/bash-ZILV3VHA.js +0 -6
- package/dist/bundle/chunks/chmod-FBHLEIY6.js +0 -8
- package/dist/bundle/chunks/chunk-4JO5BKO4.js +0 -5
- package/dist/bundle/chunks/chunk-BOJ3OAZB.js +0 -16
- package/dist/bundle/chunks/chunk-CG2HXOFG.js +0 -5
- package/dist/bundle/chunks/chunk-NWEGHOXL.js +0 -2
- package/dist/bundle/chunks/chunk-W2EKKAIL.js +0 -15
- package/dist/bundle/chunks/env-EG5SQSAQ.js +0 -8
- package/dist/bundle/chunks/od-ECWXNUB4.js +0 -6
- package/dist/bundle/chunks/printf-VG2POOXB.js +0 -13
- package/dist/bundle/chunks/pwd-AC4P3JKI.js +0 -2
- package/dist/bundle/chunks/sed-ZKODWZ6F.js +0 -79
- package/dist/bundle/chunks/touch-MVQSKQKT.js +0 -3
- package/dist/bundle/chunks/wc-DFQKWSIZ.js +0 -5
- package/dist/interpreter/builtins/variable-helpers.d.ts +0 -30
- /package/dist/bin/chunks/{curl-LCMREE7R.js → curl-TH7YRBSA.js} +0 -0
- /package/dist/bin/chunks/{file-LNCFDPQZ.js → file-6PCTL3MH.js} +0 -0
- /package/dist/bin/shell/chunks/{curl-LCMREE7R.js → curl-TH7YRBSA.js} +0 -0
- /package/dist/bin/shell/chunks/{file-LNCFDPQZ.js → file-6PCTL3MH.js} +0 -0
- /package/dist/bundle/chunks/{curl-TVZH24MD.js → curl-XLP4VABU.js} +0 -0
- /package/dist/bundle/chunks/{file-XPA6O6H2.js → file-NQP3CKRV.js} +0 -0
- /package/dist/commands/curl/{utils.d.ts → response-formatting.d.ts} +0 -0
- /package/dist/commands/xan/{xan-utils.d.ts → column-selection.d.ts} +0 -0
- /package/dist/fs/{utils.d.ts → encoding.d.ts} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builtin Command Dispatch
|
|
3
|
+
*
|
|
4
|
+
* Handles dispatch of built-in shell commands like export, unset, cd, etc.
|
|
5
|
+
* Separated from interpreter.ts for modularity.
|
|
6
|
+
*/
|
|
7
|
+
import type { ExecResult } from "../types.js";
|
|
8
|
+
import type { InterpreterContext } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Type for the function that runs a command recursively
|
|
11
|
+
*/
|
|
12
|
+
export type RunCommandFn = (commandName: string, args: string[], quotedArgs: boolean[], stdin: string, skipFunctions?: boolean, useDefaultPath?: boolean, stdinSourceFd?: number) => Promise<ExecResult>;
|
|
13
|
+
/**
|
|
14
|
+
* Type for the function that builds exported environment
|
|
15
|
+
*/
|
|
16
|
+
export type BuildExportedEnvFn = () => Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Type for the function that executes user scripts
|
|
19
|
+
*/
|
|
20
|
+
export type ExecuteUserScriptFn = (scriptPath: string, args: string[], stdin?: string) => Promise<ExecResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Dispatch context containing dependencies needed for builtin dispatch
|
|
23
|
+
*/
|
|
24
|
+
export interface BuiltinDispatchContext {
|
|
25
|
+
ctx: InterpreterContext;
|
|
26
|
+
runCommand: RunCommandFn;
|
|
27
|
+
buildExportedEnv: BuildExportedEnvFn;
|
|
28
|
+
executeUserScript: ExecuteUserScriptFn;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Dispatch a command to the appropriate builtin handler or external command.
|
|
32
|
+
* Returns null if the command should be handled by external command resolution.
|
|
33
|
+
*/
|
|
34
|
+
export declare function dispatchBuiltin(dispatchCtx: BuiltinDispatchContext, commandName: string, args: string[], _quotedArgs: boolean[], stdin: string, skipFunctions: boolean, _useDefaultPath: boolean, stdinSourceFd: number): Promise<ExecResult | null>;
|
|
35
|
+
/**
|
|
36
|
+
* Handle external command resolution and execution.
|
|
37
|
+
* Called when dispatchBuiltin returns null.
|
|
38
|
+
*/
|
|
39
|
+
export declare function executeExternalCommand(dispatchCtx: BuiltinDispatchContext, commandName: string, args: string[], stdin: string, useDefaultPath: boolean): Promise<ExecResult>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* compgen - Generate completion matches
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* compgen -v [prefix] - List variable names (optionally starting with prefix)
|
|
6
|
+
* compgen -A variable [prefix] - Same as -v
|
|
7
|
+
* compgen -A function [prefix] - List function names
|
|
8
|
+
* compgen -e [prefix] - List exported variable names
|
|
9
|
+
* compgen -A builtin [prefix] - List builtin command names
|
|
10
|
+
* compgen -A keyword [prefix] - List shell keywords (alias: -k)
|
|
11
|
+
* compgen -A alias [prefix] - List alias names
|
|
12
|
+
* compgen -A shopt [prefix] - List shopt options
|
|
13
|
+
* compgen -A helptopic [prefix] - List help topics
|
|
14
|
+
* compgen -A directory [prefix] - List directory names
|
|
15
|
+
* compgen -A file [prefix] - List file names
|
|
16
|
+
* compgen -f [prefix] - List file names (alias for -A file)
|
|
17
|
+
* compgen -A user - List user names
|
|
18
|
+
* compgen -A command [prefix] - List commands (builtins, functions, aliases, external)
|
|
19
|
+
* compgen -W wordlist [prefix] - Generate from wordlist
|
|
20
|
+
* compgen -P prefix - Prefix to add to completions
|
|
21
|
+
* compgen -S suffix - Suffix to add to completions
|
|
22
|
+
* compgen -o option - Completion option (plusdirs, dirnames, default, etc.)
|
|
23
|
+
*/
|
|
24
|
+
import type { ExecResult } from "../../types.js";
|
|
25
|
+
import type { InterpreterContext } from "../types.js";
|
|
26
|
+
export declare function handleCompgen(ctx: InterpreterContext, args: string[]): Promise<ExecResult>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* complete - Set and display programmable completion specifications
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* complete - List all completion specs
|
|
6
|
+
* complete -p - Print all completion specs in reusable format
|
|
7
|
+
* complete -p cmd - Print completion spec for specific command
|
|
8
|
+
* complete -W 'word1 word2' cmd - Set word list completion for cmd
|
|
9
|
+
* complete -F func cmd - Set function completion for cmd
|
|
10
|
+
* complete -r cmd - Remove completion spec for cmd
|
|
11
|
+
* complete -r - Remove all completion specs
|
|
12
|
+
* complete -D ... - Set default completion (for commands with no specific spec)
|
|
13
|
+
* complete -o opt cmd - Set completion options (nospace, filenames, default, etc.)
|
|
14
|
+
*/
|
|
15
|
+
import type { ExecResult } from "../../types.js";
|
|
16
|
+
import type { InterpreterContext } from "../types.js";
|
|
17
|
+
export declare function handleComplete(ctx: InterpreterContext, args: string[]): ExecResult;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* compopt - Modify completion options
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* compopt [-o option] [+o option] [name ...]
|
|
6
|
+
* compopt -D [-o option] [+o option]
|
|
7
|
+
* compopt -E [-o option] [+o option]
|
|
8
|
+
*
|
|
9
|
+
* Modifies completion options for the specified commands (names) or the
|
|
10
|
+
* currently executing completion when no names are provided.
|
|
11
|
+
*
|
|
12
|
+
* Options:
|
|
13
|
+
* -o option Enable completion option
|
|
14
|
+
* +o option Disable completion option
|
|
15
|
+
* -D Apply to default completion
|
|
16
|
+
* -E Apply to empty-line completion
|
|
17
|
+
*
|
|
18
|
+
* Valid completion options:
|
|
19
|
+
* bashdefault, default, dirnames, filenames, noquote, nosort, nospace, plusdirs
|
|
20
|
+
*
|
|
21
|
+
* Returns:
|
|
22
|
+
* 0 on success
|
|
23
|
+
* 1 if not in a completion function and no command name is given
|
|
24
|
+
* 2 if an invalid option is specified
|
|
25
|
+
*/
|
|
26
|
+
import type { ExecResult } from "../../types.js";
|
|
27
|
+
import type { InterpreterContext } from "../types.js";
|
|
28
|
+
export declare function handleCompopt(ctx: InterpreterContext, args: string[]): ExecResult;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Array Parsing Functions for declare/typeset
|
|
3
|
+
*
|
|
4
|
+
* Handles parsing of array literal syntax for the declare builtin.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Parse array elements from content like "1 2 3" or "'a b' c d"
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseArrayElements(content: string): string[];
|
|
10
|
+
/**
|
|
11
|
+
* Parse associative array literal content like "['foo']=bar ['spam']=42"
|
|
12
|
+
* Returns array of [key, value] pairs
|
|
13
|
+
*/
|
|
14
|
+
export declare function parseAssocArrayLiteral(content: string): [string, string][];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Declare Print Mode Functions
|
|
3
|
+
*
|
|
4
|
+
* Handles printing and listing variables for the declare/typeset builtin.
|
|
5
|
+
*/
|
|
6
|
+
import type { ExecResult } from "../../types.js";
|
|
7
|
+
import type { InterpreterContext } from "../types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Print specific variables with their declarations.
|
|
10
|
+
* Handles: declare -p varname1 varname2 ...
|
|
11
|
+
*/
|
|
12
|
+
export declare function printSpecificVariables(ctx: InterpreterContext, names: string[]): ExecResult;
|
|
13
|
+
export interface PrintAllFilters {
|
|
14
|
+
filterExport: boolean;
|
|
15
|
+
filterReadonly: boolean;
|
|
16
|
+
filterNameref: boolean;
|
|
17
|
+
filterIndexedArray: boolean;
|
|
18
|
+
filterAssocArray: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Print all variables with their declarations and attributes.
|
|
22
|
+
* Handles: declare -p (with optional filters like -x, -r, -n, -a, -A)
|
|
23
|
+
*/
|
|
24
|
+
export declare function printAllVariables(ctx: InterpreterContext, filters: PrintAllFilters): ExecResult;
|
|
25
|
+
/**
|
|
26
|
+
* List all associative arrays.
|
|
27
|
+
* Handles: declare -A (without arguments)
|
|
28
|
+
*/
|
|
29
|
+
export declare function listAssociativeArrays(ctx: InterpreterContext): ExecResult;
|
|
30
|
+
/**
|
|
31
|
+
* List all indexed arrays.
|
|
32
|
+
* Handles: declare -a (without arguments)
|
|
33
|
+
*/
|
|
34
|
+
export declare function listIndexedArrays(ctx: InterpreterContext): ExecResult;
|
|
35
|
+
/**
|
|
36
|
+
* List all variables without print mode (no attributes shown).
|
|
37
|
+
* Handles: declare (without -p and without arguments)
|
|
38
|
+
*/
|
|
39
|
+
export declare function listAllVariables(ctx: InterpreterContext): ExecResult;
|
|
@@ -9,16 +9,22 @@
|
|
|
9
9
|
* declare -A NAME - Declare associative array
|
|
10
10
|
* declare -r NAME - Declare readonly variable
|
|
11
11
|
* declare -x NAME - Export variable
|
|
12
|
+
* declare -g NAME - Declare global variable (inside functions)
|
|
12
13
|
*
|
|
13
14
|
* Also aliased as 'typeset'
|
|
14
15
|
*/
|
|
15
16
|
import type { ExecResult } from "../../types.js";
|
|
16
17
|
import type { InterpreterContext } from "../types.js";
|
|
17
|
-
export declare function handleDeclare(ctx: InterpreterContext, args: string[]): ExecResult;
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Check if a variable has the integer attribute.
|
|
20
20
|
*/
|
|
21
|
-
export declare function
|
|
21
|
+
export declare function isInteger(ctx: InterpreterContext, name: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Apply case transformation based on variable attributes.
|
|
24
|
+
* Returns the transformed value.
|
|
25
|
+
*/
|
|
26
|
+
export declare function applyCaseTransform(ctx: InterpreterContext, name: string, value: string): string;
|
|
27
|
+
export declare function handleDeclare(ctx: InterpreterContext, args: string[]): Promise<ExecResult>;
|
|
22
28
|
/**
|
|
23
29
|
* readonly - Declare readonly variables
|
|
24
30
|
*
|
|
@@ -26,4 +32,4 @@ export declare function parseArrayElements(content: string): string[];
|
|
|
26
32
|
* readonly NAME=value - Declare readonly variable
|
|
27
33
|
* readonly NAME - Mark existing variable as readonly
|
|
28
34
|
*/
|
|
29
|
-
export declare function handleReadonly(ctx: InterpreterContext, args: string[]): ExecResult
|
|
35
|
+
export declare function handleReadonly(ctx: InterpreterContext, args: string[]): Promise<ExecResult>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Directory Stack Builtins: pushd, popd, dirs
|
|
3
|
+
*
|
|
4
|
+
* pushd [dir] - Push directory onto stack and cd to it
|
|
5
|
+
* popd - Pop directory from stack and cd to previous
|
|
6
|
+
* dirs [-clpv] - Display directory stack
|
|
7
|
+
*/
|
|
8
|
+
import type { ExecResult } from "../../types.js";
|
|
9
|
+
import type { InterpreterContext } from "../types.js";
|
|
10
|
+
/**
|
|
11
|
+
* pushd - Push directory onto stack and cd to it
|
|
12
|
+
*
|
|
13
|
+
* pushd [dir] - Push current dir, cd to dir
|
|
14
|
+
*/
|
|
15
|
+
export declare function handlePushd(ctx: InterpreterContext, args: string[]): Promise<ExecResult>;
|
|
16
|
+
/**
|
|
17
|
+
* popd - Pop directory from stack and cd to it
|
|
18
|
+
*/
|
|
19
|
+
export declare function handlePopd(ctx: InterpreterContext, args: string[]): ExecResult;
|
|
20
|
+
/**
|
|
21
|
+
* dirs - Display directory stack
|
|
22
|
+
*
|
|
23
|
+
* dirs [-clpv]
|
|
24
|
+
* -c: Clear the stack
|
|
25
|
+
* -l: Long format (no tilde substitution)
|
|
26
|
+
* -p: One entry per line
|
|
27
|
+
* -v: One entry per line with index numbers
|
|
28
|
+
*/
|
|
29
|
+
export declare function handleDirs(ctx: InterpreterContext, args: string[]): ExecResult;
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { ExecResult } from "../../types.js";
|
|
8
8
|
import type { InterpreterContext } from "../types.js";
|
|
9
|
-
export declare function handleEval(ctx: InterpreterContext, args: string[]): Promise<ExecResult>;
|
|
9
|
+
export declare function handleEval(ctx: InterpreterContext, args: string[], stdin?: string): Promise<ExecResult>;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* export - List all exported variables
|
|
6
6
|
* export -p - List all exported variables (same as no args)
|
|
7
7
|
* export NAME=value - Set and export variable
|
|
8
|
+
* export NAME+=value - Append value and export variable
|
|
8
9
|
* export NAME - Export existing variable (or create empty)
|
|
9
10
|
* export -n NAME - Un-export variable (remove from env)
|
|
10
11
|
*/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* getopts - Parse positional parameters as options
|
|
3
|
+
*
|
|
4
|
+
* getopts optstring name [arg...]
|
|
5
|
+
*
|
|
6
|
+
* Parses options from positional parameters (or provided args).
|
|
7
|
+
* - optstring: string of valid option characters
|
|
8
|
+
* - If a character is followed by ':', it requires an argument
|
|
9
|
+
* - If optstring starts with ':', silent error reporting mode
|
|
10
|
+
* - name: variable to store the current option
|
|
11
|
+
* - OPTARG: set to the option argument (if any)
|
|
12
|
+
* - OPTIND: index of next argument to process (starts at 1)
|
|
13
|
+
*
|
|
14
|
+
* Returns 0 if option found, 1 if end of options or error.
|
|
15
|
+
*/
|
|
16
|
+
import type { ExecResult } from "../../types.js";
|
|
17
|
+
import type { InterpreterContext } from "../types.js";
|
|
18
|
+
export declare function handleGetopts(ctx: InterpreterContext, args: string[]): ExecResult;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hash - Manage the hash table of remembered command locations
|
|
3
|
+
*
|
|
4
|
+
* hash [-lr] [-p pathname] [-dt] [name ...]
|
|
5
|
+
*
|
|
6
|
+
* Hash maintains a hash table of recently executed commands for faster lookup.
|
|
7
|
+
*
|
|
8
|
+
* Options:
|
|
9
|
+
* (no args) Display the hash table
|
|
10
|
+
* name Add name to the hash table (look up in PATH)
|
|
11
|
+
* -r Clear the hash table
|
|
12
|
+
* -d name Remove name from the hash table
|
|
13
|
+
* -l Display in a format that can be reused as input
|
|
14
|
+
* -p path Use path as the full pathname for name (hash -p /path name)
|
|
15
|
+
* -t name Print the remembered location of name
|
|
16
|
+
*/
|
|
17
|
+
import type { ExecResult } from "../../types.js";
|
|
18
|
+
import type { InterpreterContext } from "../types.js";
|
|
19
|
+
export declare function handleHash(ctx: InterpreterContext, args: string[]): Promise<ExecResult>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* help - Display helpful information about builtin commands
|
|
3
|
+
*
|
|
4
|
+
* Usage: help [-s] [pattern ...]
|
|
5
|
+
*
|
|
6
|
+
* If PATTERN is specified, gives detailed help on all commands matching PATTERN,
|
|
7
|
+
* otherwise a list of the builtins is printed. The -s option restricts the output
|
|
8
|
+
* for each builtin command matching PATTERN to a short usage synopsis.
|
|
9
|
+
*/
|
|
10
|
+
import type { ExecResult } from "../../types.js";
|
|
11
|
+
import type { InterpreterContext } from "../types.js";
|
|
12
|
+
export declare function handleHelp(_ctx: InterpreterContext, args: string[]): ExecResult;
|
|
@@ -21,11 +21,18 @@
|
|
|
21
21
|
*/
|
|
22
22
|
export { handleBreak } from "./break.js";
|
|
23
23
|
export { handleCd } from "./cd.js";
|
|
24
|
+
export { handleCompgen } from "./compgen.js";
|
|
25
|
+
export { handleComplete } from "./complete.js";
|
|
26
|
+
export { handleCompopt } from "./compopt.js";
|
|
24
27
|
export { handleContinue } from "./continue.js";
|
|
25
|
-
export { handleDeclare, handleReadonly } from "./declare.js";
|
|
28
|
+
export { applyCaseTransform, handleDeclare, handleReadonly, isInteger, } from "./declare.js";
|
|
29
|
+
export { handleDirs, handlePopd, handlePushd } from "./dirs.js";
|
|
26
30
|
export { handleEval } from "./eval.js";
|
|
27
31
|
export { handleExit } from "./exit.js";
|
|
28
32
|
export { handleExport } from "./export.js";
|
|
33
|
+
export { handleGetopts } from "./getopts.js";
|
|
34
|
+
export { handleHash } from "./hash.js";
|
|
35
|
+
export { handleHelp } from "./help.js";
|
|
29
36
|
export { handleLet } from "./let.js";
|
|
30
37
|
export { handleLocal } from "./local.js";
|
|
31
38
|
export { handleMapfile } from "./mapfile.js";
|
|
@@ -35,3 +42,4 @@ export { handleSet } from "./set.js";
|
|
|
35
42
|
export { handleShift } from "./shift.js";
|
|
36
43
|
export { handleSource } from "./source.js";
|
|
37
44
|
export { handleUnset } from "./unset.js";
|
|
45
|
+
export { getLocalVarDepth } from "./variable-assignment.js";
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ExecResult } from "../../types.js";
|
|
5
5
|
import type { InterpreterContext } from "../types.js";
|
|
6
|
-
export declare function handleLocal(ctx: InterpreterContext, args: string[]): ExecResult
|
|
6
|
+
export declare function handleLocal(ctx: InterpreterContext, args: string[]): Promise<ExecResult>;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ExecResult } from "../../types.js";
|
|
5
5
|
import type { InterpreterContext } from "../types.js";
|
|
6
|
-
export declare function handleRead(ctx: InterpreterContext, args: string[], stdin: string): ExecResult;
|
|
6
|
+
export declare function handleRead(ctx: InterpreterContext, args: string[], stdin: string, stdinSourceFd?: number): ExecResult;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* set - Set/unset shell options builtin
|
|
3
|
+
*
|
|
4
|
+
* In POSIX mode (set -o posix), errors from set (like invalid options)
|
|
5
|
+
* cause the script to exit immediately.
|
|
3
6
|
*/
|
|
4
7
|
import type { ExecResult } from "../../types.js";
|
|
5
8
|
import type { InterpreterContext } from "../types.js";
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
* Shifts positional parameters to the left by n (default 1).
|
|
7
7
|
* $n+1 becomes $1, $n+2 becomes $2, etc.
|
|
8
8
|
* $# is decremented by n.
|
|
9
|
+
*
|
|
10
|
+
* In POSIX mode (set -o posix), errors from shift (like shift count
|
|
11
|
+
* exceeding available parameters) cause the script to exit immediately.
|
|
9
12
|
*/
|
|
10
13
|
import type { ExecResult } from "../../types.js";
|
|
11
14
|
import type { InterpreterContext } from "../types.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* shopt builtin - Shell options
|
|
3
|
+
* Implements bash's shopt builtin for managing shell-specific options
|
|
4
|
+
*/
|
|
5
|
+
import type { ExecResult } from "../../types.js";
|
|
6
|
+
import type { InterpreterContext } from "../types.js";
|
|
7
|
+
export declare function handleShopt(ctx: InterpreterContext, args: string[]): ExecResult;
|
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
* - unset -v VAR - remove variable (explicit)
|
|
7
7
|
* - unset -f FUNC - remove function
|
|
8
8
|
* - unset 'a[i]' - remove array element (with arithmetic index support)
|
|
9
|
+
*
|
|
10
|
+
* Bash-specific unset scoping:
|
|
11
|
+
* - local-unset (same scope): value-unset - clears value but keeps local cell
|
|
12
|
+
* - dynamic-unset (different scope): cell-unset - removes local cell, exposes outer value
|
|
9
13
|
*/
|
|
10
14
|
import type { ExecResult } from "../../types.js";
|
|
11
15
|
import type { InterpreterContext } from "../types.js";
|
|
12
|
-
export declare function handleUnset(ctx: InterpreterContext, args: string[]): ExecResult
|
|
16
|
+
export declare function handleUnset(ctx: InterpreterContext, args: string[]): Promise<ExecResult>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Variable assignment helpers for declare, readonly, local, export builtins.
|
|
3
|
+
*/
|
|
4
|
+
import type { ExecResult } from "../../types.js";
|
|
5
|
+
import type { InterpreterContext } from "../types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Result of parsing an assignment argument.
|
|
8
|
+
*/
|
|
9
|
+
export interface ParsedAssignment {
|
|
10
|
+
name: string;
|
|
11
|
+
isArray: boolean;
|
|
12
|
+
arrayElements?: string[];
|
|
13
|
+
value?: string;
|
|
14
|
+
/** For array index assignment: a[index]=value */
|
|
15
|
+
arrayIndex?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Parse an assignment argument like "name=value", "name=(a b c)", or "name[index]=value".
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseAssignment(arg: string): ParsedAssignment;
|
|
21
|
+
/**
|
|
22
|
+
* Options for setting a variable.
|
|
23
|
+
*/
|
|
24
|
+
export interface SetVariableOptions {
|
|
25
|
+
makeReadonly?: boolean;
|
|
26
|
+
checkReadonly?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Set a variable from a parsed assignment.
|
|
30
|
+
* Returns an error result if the variable is readonly, otherwise null.
|
|
31
|
+
*/
|
|
32
|
+
export declare function setVariable(ctx: InterpreterContext, assignment: ParsedAssignment, options?: SetVariableOptions): Promise<ExecResult | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Mark a variable as being declared at the current call depth.
|
|
35
|
+
* Used for bash-specific unset scoping behavior.
|
|
36
|
+
*/
|
|
37
|
+
export declare function markLocalVarDepth(ctx: InterpreterContext, name: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Get the call depth at which a local variable was declared.
|
|
40
|
+
* Returns undefined if the variable is not a local variable.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getLocalVarDepth(ctx: InterpreterContext, name: string): number | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Clear the local variable depth tracking for a variable.
|
|
45
|
+
* Called when a local variable is cell-unset (dynamic-unset).
|
|
46
|
+
*/
|
|
47
|
+
export declare function clearLocalVarDepth(ctx: InterpreterContext, name: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Push the current value of a variable onto the local var stack.
|
|
50
|
+
* Used for bash's localvar-nest behavior where nested local declarations
|
|
51
|
+
* each create a new cell that can be unset independently.
|
|
52
|
+
*/
|
|
53
|
+
export declare function pushLocalVarStack(ctx: InterpreterContext, name: string, currentValue: string | undefined): void;
|
|
54
|
+
/**
|
|
55
|
+
* Pop the top entry from the local var stack for a variable.
|
|
56
|
+
* Returns the saved value and scope index if there was an entry, or undefined if the stack was empty.
|
|
57
|
+
*/
|
|
58
|
+
export declare function popLocalVarStack(ctx: InterpreterContext, name: string): {
|
|
59
|
+
value: string | undefined;
|
|
60
|
+
scopeIndex: number;
|
|
61
|
+
} | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Clear all local var stack entries for a specific scope index.
|
|
64
|
+
* Called when a function returns and its local scope is popped.
|
|
65
|
+
*/
|
|
66
|
+
export declare function clearLocalVarStackForScope(ctx: InterpreterContext, scopeIndex: number): void;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command Resolution
|
|
3
|
+
*
|
|
4
|
+
* Handles PATH-based command resolution and lookup for external commands.
|
|
5
|
+
*/
|
|
6
|
+
import type { IFileSystem } from "../fs/interface.js";
|
|
7
|
+
import type { Command, CommandRegistry } from "../types.js";
|
|
8
|
+
import type { InterpreterState } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Context needed for command resolution
|
|
11
|
+
*/
|
|
12
|
+
export interface CommandResolutionContext {
|
|
13
|
+
fs: IFileSystem;
|
|
14
|
+
state: InterpreterState;
|
|
15
|
+
commands: CommandRegistry;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Result type for command resolution
|
|
19
|
+
*/
|
|
20
|
+
export type ResolveCommandResult = {
|
|
21
|
+
cmd: Command;
|
|
22
|
+
path: string;
|
|
23
|
+
} | {
|
|
24
|
+
script: true;
|
|
25
|
+
path: string;
|
|
26
|
+
} | {
|
|
27
|
+
error: "not_found" | "permission_denied";
|
|
28
|
+
path?: string;
|
|
29
|
+
} | null;
|
|
30
|
+
/**
|
|
31
|
+
* Resolve a command name to its implementation via PATH lookup.
|
|
32
|
+
* Returns the command and its resolved path, or null if not found.
|
|
33
|
+
*
|
|
34
|
+
* Resolution order:
|
|
35
|
+
* 1. If command contains "/", resolve as a path
|
|
36
|
+
* 2. Search PATH directories for the command file
|
|
37
|
+
* 3. Fall back to registry lookup (for non-InMemoryFs filesystems like OverlayFs)
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveCommand(ctx: CommandResolutionContext, commandName: string, pathOverride?: string): Promise<ResolveCommandResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Find all paths for a command in PATH (for `which -a`).
|
|
42
|
+
*/
|
|
43
|
+
export declare function findCommandInPath(ctx: CommandResolutionContext, commandName: string): Promise<string[]>;
|
|
@@ -14,4 +14,4 @@ import type { ExecResult } from "../types.js";
|
|
|
14
14
|
import type { InterpreterContext } from "./types.js";
|
|
15
15
|
export declare function evaluateConditional(ctx: InterpreterContext, expr: ConditionalExpressionNode): Promise<boolean>;
|
|
16
16
|
export declare function evaluateTestArgs(ctx: InterpreterContext, args: string[]): Promise<ExecResult>;
|
|
17
|
-
export declare function matchPattern(value: string, pattern: string): boolean;
|
|
17
|
+
export declare function matchPattern(value: string, pattern: string, nocasematch?: boolean, extglob?: boolean): boolean;
|
|
@@ -78,7 +78,12 @@ export declare class ExitError extends ControlFlowError {
|
|
|
78
78
|
*/
|
|
79
79
|
export declare class ArithmeticError extends ControlFlowError {
|
|
80
80
|
readonly name = "ArithmeticError";
|
|
81
|
-
|
|
81
|
+
/**
|
|
82
|
+
* If true, this error should abort script execution (like missing operand after binary operator).
|
|
83
|
+
* If false, the error is recoverable and execution can continue.
|
|
84
|
+
*/
|
|
85
|
+
fatal: boolean;
|
|
86
|
+
constructor(message: string, stdout?: string, stderr?: string, fatal?: boolean);
|
|
82
87
|
}
|
|
83
88
|
/**
|
|
84
89
|
* Error thrown for bad substitution errors (e.g., ${#var:1:3}).
|
|
@@ -88,6 +93,22 @@ export declare class BadSubstitutionError extends ControlFlowError {
|
|
|
88
93
|
readonly name = "BadSubstitutionError";
|
|
89
94
|
constructor(message: string, stdout?: string, stderr?: string);
|
|
90
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Error thrown when failglob is enabled and a glob pattern has no matches.
|
|
98
|
+
* Returns exit code 1.
|
|
99
|
+
*/
|
|
100
|
+
export declare class GlobError extends ControlFlowError {
|
|
101
|
+
readonly name = "GlobError";
|
|
102
|
+
constructor(pattern: string, stdout?: string, stderr?: string);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Error thrown for invalid brace expansions (e.g., mixed case character ranges like {z..A}).
|
|
106
|
+
* Returns exit code 1 (matching bash behavior).
|
|
107
|
+
*/
|
|
108
|
+
export declare class BraceExpansionError extends ControlFlowError {
|
|
109
|
+
readonly name = "BraceExpansionError";
|
|
110
|
+
constructor(message: string, stdout?: string, stderr?: string);
|
|
111
|
+
}
|
|
91
112
|
/**
|
|
92
113
|
* Error thrown when execution limits are exceeded (recursion depth, command count, loop iterations).
|
|
93
114
|
* This should ALWAYS be thrown before JavaScript's native RangeError kicks in.
|
|
@@ -112,4 +133,18 @@ export declare class SubshellExitError extends ControlFlowError {
|
|
|
112
133
|
* These need special handling vs errexit/nounset which terminate execution.
|
|
113
134
|
*/
|
|
114
135
|
export declare function isScopeExitError(error: unknown): error is BreakError | ContinueError | ReturnError;
|
|
136
|
+
/**
|
|
137
|
+
* Error thrown when a POSIX special builtin fails in POSIX mode.
|
|
138
|
+
* In POSIX mode (set -o posix), errors in special builtins like
|
|
139
|
+
* shift, set, readonly, export, etc. cause the entire script to exit.
|
|
140
|
+
*
|
|
141
|
+
* Per POSIX 2.8.1 - Consequences of Shell Errors:
|
|
142
|
+
* "A special built-in utility causes an interactive or non-interactive shell
|
|
143
|
+
* to exit when an error occurs."
|
|
144
|
+
*/
|
|
145
|
+
export declare class PosixFatalError extends ControlFlowError {
|
|
146
|
+
readonly exitCode: number;
|
|
147
|
+
readonly name = "PosixFatalError";
|
|
148
|
+
constructor(exitCode: number, stdout?: string, stderr?: string);
|
|
149
|
+
}
|
|
115
150
|
export {};
|
|
@@ -1,28 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Word Analysis
|
|
3
3
|
*
|
|
4
|
-
* Functions for analyzing word parts to determine
|
|
5
|
-
* - Whether async execution is needed
|
|
6
|
-
* - What types of expansions are present
|
|
4
|
+
* Functions for analyzing word parts to determine what types of expansions are present.
|
|
7
5
|
*/
|
|
8
|
-
import type { ParameterExpansionPart,
|
|
6
|
+
import type { ParameterExpansionPart, WordPart } from "../../ast/types.js";
|
|
9
7
|
/**
|
|
10
|
-
* Check if a
|
|
8
|
+
* Check if a glob pattern string contains variable references ($var or ${var})
|
|
9
|
+
* This is used to detect when IFS splitting should apply to expanded glob patterns.
|
|
11
10
|
*/
|
|
12
|
-
export declare function
|
|
11
|
+
export declare function globPatternHasVarRef(pattern: string): boolean;
|
|
13
12
|
/**
|
|
14
|
-
* Check if a word
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Check if a parameter expansion has quoted parts in its operation word
|
|
23
|
-
* e.g., ${v:-"AxBxC"} has a quoted default value
|
|
13
|
+
* Check if a parameter expansion's operation word is entirely quoted (all parts are quoted).
|
|
14
|
+
* This is different from hasQuotedOperationWord which returns true if ANY part is quoted.
|
|
15
|
+
*
|
|
16
|
+
* For word splitting purposes:
|
|
17
|
+
* - ${v:-"AxBxC"} - entirely quoted, should NOT be split
|
|
18
|
+
* - ${v:-x"AxBxC"x} - mixed quoted/unquoted, SHOULD be split (on unquoted parts)
|
|
19
|
+
* - ${v:-AxBxC} - entirely unquoted, SHOULD be split
|
|
24
20
|
*/
|
|
25
|
-
export declare function
|
|
21
|
+
export declare function isOperationWordEntirelyQuoted(part: ParameterExpansionPart): boolean;
|
|
26
22
|
/**
|
|
27
23
|
* Result of analyzing word parts
|
|
28
24
|
*/
|
|
@@ -32,6 +28,8 @@ export interface WordPartsAnalysis {
|
|
|
32
28
|
hasArrayVar: boolean;
|
|
33
29
|
hasArrayAtExpansion: boolean;
|
|
34
30
|
hasParamExpansion: boolean;
|
|
31
|
+
hasVarNamePrefixExpansion: boolean;
|
|
32
|
+
hasIndirection: boolean;
|
|
35
33
|
}
|
|
36
34
|
/**
|
|
37
35
|
* Analyze word parts for expansion behavior
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arithmetic Text Expansion
|
|
3
|
+
*
|
|
4
|
+
* Functions for expanding variables within arithmetic expression text.
|
|
5
|
+
* This handles the bash behavior where $(( $x * 3 )) with x='1 + 2' should
|
|
6
|
+
* expand to $(( 1 + 2 * 3 )) = 7, not $(( (1+2) * 3 )) = 9.
|
|
7
|
+
*/
|
|
8
|
+
import type { InterpreterContext } from "../types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Expand $var patterns in arithmetic expression text for text substitution.
|
|
11
|
+
* Only expands simple $var patterns, not ${...}, $(()), $(), etc.
|
|
12
|
+
*/
|
|
13
|
+
export declare function expandDollarVarsInArithText(ctx: InterpreterContext, text: string): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* Expand variable references and command substitutions in an array subscript.
|
|
16
|
+
* e.g., "${array[@]}" -> "1 2 3", "$(echo 1)" -> "1"
|
|
17
|
+
* This is needed for associative array subscripts like assoc["${array[@]}"]
|
|
18
|
+
* where the subscript may contain variable or array expansions.
|
|
19
|
+
*/
|
|
20
|
+
export declare function expandSubscriptForAssocArray(ctx: InterpreterContext, subscript: string): Promise<string>;
|