just-bash 1.0.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/LICENSE +201 -0
- package/README.md +326 -0
- package/dist/Bash.d.ts +90 -0
- package/dist/ai/index.d.ts +56 -0
- package/dist/ast/types.d.ts +518 -0
- package/dist/bin/chunks/alias-74DFXE2E.js +7 -0
- package/dist/bin/chunks/awk-S63F6IYK.js +15 -0
- package/dist/bin/chunks/base64-NC7HTKLZ.js +5 -0
- package/dist/bin/chunks/basename-Y7JDBYHN.js +6 -0
- package/dist/bin/chunks/bash-TQGTNXAE.js +7 -0
- package/dist/bin/chunks/cat-YZXBF5YF.js +6 -0
- package/dist/bin/chunks/chmod-3G4LK462.js +9 -0
- package/dist/bin/chunks/chunk-26Q3PZQ6.js +2 -0
- package/dist/bin/chunks/chunk-4VDEBYW7.js +2 -0
- package/dist/bin/chunks/chunk-5KNEBKYN.js +2 -0
- package/dist/bin/chunks/chunk-GTNBSMZR.js +23 -0
- package/dist/bin/chunks/chunk-J7BCMQDI.js +16 -0
- package/dist/bin/chunks/chunk-J7MJV6WO.js +3 -0
- package/dist/bin/chunks/chunk-LV662IGP.js +6 -0
- package/dist/bin/chunks/chunk-TA7RUHGQ.js +4 -0
- package/dist/bin/chunks/clear-GTCFHSB2.js +2 -0
- package/dist/bin/chunks/cp-77UY7PGN.js +8 -0
- package/dist/bin/chunks/curl-NE7XEWMN.js +26 -0
- package/dist/bin/chunks/cut-UYV3FM7R.js +6 -0
- package/dist/bin/chunks/date-7NBRXV2Z.js +5 -0
- package/dist/bin/chunks/diff-TG2NXCX2.js +19 -0
- package/dist/bin/chunks/dirname-VLHP44TU.js +5 -0
- package/dist/bin/chunks/du-4FZ7WF2P.js +8 -0
- package/dist/bin/chunks/echo-DEUIS5JO.js +4 -0
- package/dist/bin/chunks/env-FVITWNHG.js +9 -0
- package/dist/bin/chunks/expr-HA2ZNL6S.js +5 -0
- package/dist/bin/chunks/find-4B67H4RP.js +11 -0
- package/dist/bin/chunks/grep-OVWU4WCZ.js +15 -0
- package/dist/bin/chunks/head-VGXR3WWL.js +2 -0
- package/dist/bin/chunks/help-5V3MPCYQ.js +16 -0
- package/dist/bin/chunks/history-PRQ4B6N2.js +3 -0
- package/dist/bin/chunks/html-to-markdown-L4UWMK4S.js +84 -0
- package/dist/bin/chunks/jq-EYSXBSCP.js +14 -0
- package/dist/bin/chunks/ln-DB7J2W5X.js +10 -0
- package/dist/bin/chunks/ls-C4MPAF3H.js +26 -0
- package/dist/bin/chunks/mkdir-LWULWDHP.js +7 -0
- package/dist/bin/chunks/mv-TDYCNSIQ.js +7 -0
- package/dist/bin/chunks/paste-R36J3G4K.js +8 -0
- package/dist/bin/chunks/printf-BOFQVMMK.js +15 -0
- package/dist/bin/chunks/pwd-X4MWD4JP.js +3 -0
- package/dist/bin/chunks/readlink-DPNOQY67.js +7 -0
- package/dist/bin/chunks/rm-W6CCBEMG.js +8 -0
- package/dist/bin/chunks/sed-7IS44XON.js +48 -0
- package/dist/bin/chunks/seq-DGJILX2Q.js +7 -0
- package/dist/bin/chunks/sleep-E4DIYGTT.js +10 -0
- package/dist/bin/chunks/sort-UJP353TM.js +15 -0
- package/dist/bin/chunks/stat-3PHITCPO.js +9 -0
- package/dist/bin/chunks/tail-YSVKBQ77.js +2 -0
- package/dist/bin/chunks/tee-UU2VS3OM.js +3 -0
- package/dist/bin/chunks/timeout-OZVAGW2H.js +12 -0
- package/dist/bin/chunks/touch-XCIAYF5I.js +4 -0
- package/dist/bin/chunks/tr-2EEKHHO6.js +20 -0
- package/dist/bin/chunks/tree-4247W67O.js +12 -0
- package/dist/bin/chunks/true-JCX733LK.js +2 -0
- package/dist/bin/chunks/uniq-W4HF6YSB.js +5 -0
- package/dist/bin/chunks/wc-CNJ3QDRA.js +6 -0
- package/dist/bin/chunks/which-HX2NMOP3.js +3 -0
- package/dist/bin/chunks/xargs-YNLVLPOF.js +4 -0
- package/dist/bin/just-bash.js +188 -0
- package/dist/bin/shell/chunks/alias-74DFXE2E.js +7 -0
- package/dist/bin/shell/chunks/awk-S63F6IYK.js +15 -0
- package/dist/bin/shell/chunks/base64-NC7HTKLZ.js +5 -0
- package/dist/bin/shell/chunks/basename-Y7JDBYHN.js +6 -0
- package/dist/bin/shell/chunks/bash-TQGTNXAE.js +7 -0
- package/dist/bin/shell/chunks/cat-YZXBF5YF.js +6 -0
- package/dist/bin/shell/chunks/chmod-3G4LK462.js +9 -0
- package/dist/bin/shell/chunks/chunk-26Q3PZQ6.js +2 -0
- package/dist/bin/shell/chunks/chunk-4VDEBYW7.js +2 -0
- package/dist/bin/shell/chunks/chunk-5KNEBKYN.js +2 -0
- package/dist/bin/shell/chunks/chunk-GTNBSMZR.js +23 -0
- package/dist/bin/shell/chunks/chunk-J7BCMQDI.js +16 -0
- package/dist/bin/shell/chunks/chunk-J7MJV6WO.js +3 -0
- package/dist/bin/shell/chunks/chunk-LV662IGP.js +6 -0
- package/dist/bin/shell/chunks/chunk-TA7RUHGQ.js +4 -0
- package/dist/bin/shell/chunks/clear-GTCFHSB2.js +2 -0
- package/dist/bin/shell/chunks/cp-77UY7PGN.js +8 -0
- package/dist/bin/shell/chunks/curl-NE7XEWMN.js +26 -0
- package/dist/bin/shell/chunks/cut-UYV3FM7R.js +6 -0
- package/dist/bin/shell/chunks/date-7NBRXV2Z.js +5 -0
- package/dist/bin/shell/chunks/diff-TG2NXCX2.js +19 -0
- package/dist/bin/shell/chunks/dirname-VLHP44TU.js +5 -0
- package/dist/bin/shell/chunks/du-4FZ7WF2P.js +8 -0
- package/dist/bin/shell/chunks/echo-DEUIS5JO.js +4 -0
- package/dist/bin/shell/chunks/env-FVITWNHG.js +9 -0
- package/dist/bin/shell/chunks/expr-HA2ZNL6S.js +5 -0
- package/dist/bin/shell/chunks/find-4B67H4RP.js +11 -0
- package/dist/bin/shell/chunks/grep-OVWU4WCZ.js +15 -0
- package/dist/bin/shell/chunks/head-VGXR3WWL.js +2 -0
- package/dist/bin/shell/chunks/help-5V3MPCYQ.js +16 -0
- package/dist/bin/shell/chunks/history-PRQ4B6N2.js +3 -0
- package/dist/bin/shell/chunks/html-to-markdown-L4UWMK4S.js +84 -0
- package/dist/bin/shell/chunks/jq-EYSXBSCP.js +14 -0
- package/dist/bin/shell/chunks/ln-DB7J2W5X.js +10 -0
- package/dist/bin/shell/chunks/ls-C4MPAF3H.js +26 -0
- package/dist/bin/shell/chunks/mkdir-LWULWDHP.js +7 -0
- package/dist/bin/shell/chunks/mv-TDYCNSIQ.js +7 -0
- package/dist/bin/shell/chunks/paste-R36J3G4K.js +8 -0
- package/dist/bin/shell/chunks/printf-BOFQVMMK.js +15 -0
- package/dist/bin/shell/chunks/pwd-X4MWD4JP.js +3 -0
- package/dist/bin/shell/chunks/readlink-DPNOQY67.js +7 -0
- package/dist/bin/shell/chunks/rm-W6CCBEMG.js +8 -0
- package/dist/bin/shell/chunks/sed-7IS44XON.js +48 -0
- package/dist/bin/shell/chunks/seq-DGJILX2Q.js +7 -0
- package/dist/bin/shell/chunks/sleep-E4DIYGTT.js +10 -0
- package/dist/bin/shell/chunks/sort-UJP353TM.js +15 -0
- package/dist/bin/shell/chunks/stat-3PHITCPO.js +9 -0
- package/dist/bin/shell/chunks/tail-YSVKBQ77.js +2 -0
- package/dist/bin/shell/chunks/tee-UU2VS3OM.js +3 -0
- package/dist/bin/shell/chunks/timeout-OZVAGW2H.js +12 -0
- package/dist/bin/shell/chunks/touch-XCIAYF5I.js +4 -0
- package/dist/bin/shell/chunks/tr-2EEKHHO6.js +20 -0
- package/dist/bin/shell/chunks/tree-4247W67O.js +12 -0
- package/dist/bin/shell/chunks/true-JCX733LK.js +2 -0
- package/dist/bin/shell/chunks/uniq-W4HF6YSB.js +5 -0
- package/dist/bin/shell/chunks/wc-CNJ3QDRA.js +6 -0
- package/dist/bin/shell/chunks/which-HX2NMOP3.js +3 -0
- package/dist/bin/shell/chunks/xargs-YNLVLPOF.js +4 -0
- package/dist/bin/shell/shell.js +172 -0
- package/dist/bundle/ai/index.js +541 -0
- package/dist/bundle/chunks/alias-7ZSTROM7.js +6 -0
- package/dist/bundle/chunks/awk-V4C3GTJI.js +14 -0
- package/dist/bundle/chunks/base64-WATI5PWI.js +4 -0
- package/dist/bundle/chunks/basename-SB5JXIY3.js +5 -0
- package/dist/bundle/chunks/bash-T4PXVRYX.js +6 -0
- package/dist/bundle/chunks/cat-5KESXK2M.js +5 -0
- package/dist/bundle/chunks/chmod-VLKWIL3N.js +8 -0
- package/dist/bundle/chunks/chunk-3YNHMZ5M.js +2 -0
- package/dist/bundle/chunks/chunk-44UOCSGV.js +1 -0
- package/dist/bundle/chunks/chunk-74CEPOFO.js +22 -0
- package/dist/bundle/chunks/chunk-JYYFSUWP.js +5 -0
- package/dist/bundle/chunks/chunk-UJMN5NLH.js +1 -0
- package/dist/bundle/chunks/chunk-W2EKKAIL.js +15 -0
- package/dist/bundle/chunks/chunk-ZVV5VXYZ.js +3 -0
- package/dist/bundle/chunks/clear-ZBD2DMXN.js +1 -0
- package/dist/bundle/chunks/cp-BLHAPLQZ.js +7 -0
- package/dist/bundle/chunks/curl-PA2MWGKN.js +25 -0
- package/dist/bundle/chunks/cut-7RHEYJ7Y.js +5 -0
- package/dist/bundle/chunks/date-YOOSNZVA.js +4 -0
- package/dist/bundle/chunks/diff-IVJFQANX.js +6 -0
- package/dist/bundle/chunks/dirname-Q5HDZLH2.js +4 -0
- package/dist/bundle/chunks/du-I5HYAKTQ.js +7 -0
- package/dist/bundle/chunks/echo-W2TA2N7Y.js +3 -0
- package/dist/bundle/chunks/env-OORA5GFS.js +8 -0
- package/dist/bundle/chunks/expr-A4LJAGVP.js +4 -0
- package/dist/bundle/chunks/find-K3NO35MZ.js +10 -0
- package/dist/bundle/chunks/grep-3D2INI4S.js +14 -0
- package/dist/bundle/chunks/head-7H5R4WKO.js +1 -0
- package/dist/bundle/chunks/help-SDCRRU2F.js +15 -0
- package/dist/bundle/chunks/history-7Z2STZ6Y.js +2 -0
- package/dist/bundle/chunks/html-to-markdown-XMBYO6FD.js +4 -0
- package/dist/bundle/chunks/jq-7R2XGLLH.js +13 -0
- package/dist/bundle/chunks/ln-UTUVIAFP.js +9 -0
- package/dist/bundle/chunks/ls-B7C35UDO.js +23 -0
- package/dist/bundle/chunks/mkdir-WYI2LJ6H.js +6 -0
- package/dist/bundle/chunks/mv-GN23UIZU.js +6 -0
- package/dist/bundle/chunks/paste-L4TYPVSP.js +7 -0
- package/dist/bundle/chunks/printf-3ZT5XOIZ.js +14 -0
- package/dist/bundle/chunks/pwd-ZVX5RTL4.js +2 -0
- package/dist/bundle/chunks/readlink-HHC33N5C.js +6 -0
- package/dist/bundle/chunks/rm-5X2XSQQ6.js +7 -0
- package/dist/bundle/chunks/sed-UZJSXYQZ.js +47 -0
- package/dist/bundle/chunks/seq-TFPZQZPJ.js +6 -0
- package/dist/bundle/chunks/sleep-QJBQD6VS.js +9 -0
- package/dist/bundle/chunks/sort-LHMQWYH2.js +14 -0
- package/dist/bundle/chunks/stat-TM5F5YO4.js +8 -0
- package/dist/bundle/chunks/tail-BLGGG2VX.js +1 -0
- package/dist/bundle/chunks/tee-VCNOG5VI.js +2 -0
- package/dist/bundle/chunks/timeout-THAT7IOO.js +11 -0
- package/dist/bundle/chunks/touch-Z5XRYFYY.js +3 -0
- package/dist/bundle/chunks/tr-UV4V27RJ.js +19 -0
- package/dist/bundle/chunks/tree-75UXQ4XJ.js +11 -0
- package/dist/bundle/chunks/true-OD7ZXH3O.js +1 -0
- package/dist/bundle/chunks/uniq-IIOQKNTS.js +4 -0
- package/dist/bundle/chunks/wc-OXLYBRUE.js +5 -0
- package/dist/bundle/chunks/which-ONWH3TNF.js +2 -0
- package/dist/bundle/chunks/xargs-E5JPQL24.js +3 -0
- package/dist/bundle/index.js +141 -0
- package/dist/commands/alias/alias.d.ts +3 -0
- package/dist/commands/awk/awk.d.ts +2 -0
- package/dist/commands/awk/executor.d.ts +3 -0
- package/dist/commands/awk/expressions.d.ts +3 -0
- package/dist/commands/awk/functions.d.ts +12 -0
- package/dist/commands/awk/parser.d.ts +3 -0
- package/dist/commands/awk/types.d.ts +44 -0
- package/dist/commands/base64/base64.d.ts +5 -0
- package/dist/commands/basename/basename.d.ts +2 -0
- package/dist/commands/bash/bash.d.ts +3 -0
- package/dist/commands/cat/cat.d.ts +2 -0
- package/dist/commands/chmod/chmod.d.ts +2 -0
- package/dist/commands/clear/clear.d.ts +2 -0
- package/dist/commands/cp/cp.d.ts +2 -0
- package/dist/commands/curl/curl.d.ts +8 -0
- package/dist/commands/curl/form.d.ts +21 -0
- package/dist/commands/curl/help.d.ts +9 -0
- package/dist/commands/curl/parse.d.ts +9 -0
- package/dist/commands/curl/types.d.ts +31 -0
- package/dist/commands/curl/utils.d.ts +20 -0
- package/dist/commands/cut/cut.d.ts +2 -0
- package/dist/commands/date/date.d.ts +5 -0
- package/dist/commands/diff/diff.d.ts +5 -0
- package/dist/commands/dirname/dirname.d.ts +2 -0
- package/dist/commands/du/du.d.ts +2 -0
- package/dist/commands/echo/echo.d.ts +2 -0
- package/dist/commands/env/env.d.ts +3 -0
- package/dist/commands/expr/expr.d.ts +7 -0
- package/dist/commands/find/find.d.ts +2 -0
- package/dist/commands/find/matcher.d.ts +3 -0
- package/dist/commands/find/parser.d.ts +2 -0
- package/dist/commands/find/types.d.ts +70 -0
- package/dist/commands/grep/grep.d.ts +4 -0
- package/dist/commands/head/head-tail-shared.d.ts +38 -0
- package/dist/commands/head/head.d.ts +2 -0
- package/dist/commands/help/help.d.ts +2 -0
- package/dist/commands/help.d.ts +16 -0
- package/dist/commands/history/history.d.ts +2 -0
- package/dist/commands/html-to-markdown/html-to-markdown.d.ts +7 -0
- package/dist/commands/jq/jq.d.ts +14 -0
- package/dist/commands/ln/ln.d.ts +2 -0
- package/dist/commands/ls/ls.d.ts +2 -0
- package/dist/commands/mkdir/mkdir.d.ts +2 -0
- package/dist/commands/mv/mv.d.ts +2 -0
- package/dist/commands/paste/paste.d.ts +2 -0
- package/dist/commands/printf/printf.d.ts +2 -0
- package/dist/commands/pwd/pwd.d.ts +2 -0
- package/dist/commands/readlink/readlink.d.ts +2 -0
- package/dist/commands/registry.d.ts +33 -0
- package/dist/commands/rm/rm.d.ts +2 -0
- package/dist/commands/sed/executor.d.ts +7 -0
- package/dist/commands/sed/parser.d.ts +5 -0
- package/dist/commands/sed/sed.d.ts +2 -0
- package/dist/commands/sed/types.d.ts +141 -0
- package/dist/commands/seq/seq.d.ts +14 -0
- package/dist/commands/sleep/sleep.d.ts +2 -0
- package/dist/commands/sort/comparator.d.ts +9 -0
- package/dist/commands/sort/parser.d.ts +11 -0
- package/dist/commands/sort/sort.d.ts +2 -0
- package/dist/commands/sort/types.d.ts +18 -0
- package/dist/commands/stat/stat.d.ts +2 -0
- package/dist/commands/tail/tail.d.ts +2 -0
- package/dist/commands/tee/tee.d.ts +2 -0
- package/dist/commands/timeout/timeout.d.ts +2 -0
- package/dist/commands/touch/touch.d.ts +2 -0
- package/dist/commands/tr/tr.d.ts +2 -0
- package/dist/commands/tree/tree.d.ts +2 -0
- package/dist/commands/true/true.d.ts +3 -0
- package/dist/commands/uniq/uniq.d.ts +2 -0
- package/dist/commands/wc/wc.d.ts +2 -0
- package/dist/commands/which/which.d.ts +2 -0
- package/dist/commands/xargs/xargs.d.ts +2 -0
- package/dist/fs-interface.d.ts +186 -0
- package/dist/fs.d.ts +39 -0
- package/dist/index.d.ts +12 -0
- package/dist/interpreter/arithmetic.d.ts +29 -0
- package/dist/interpreter/builtins/break.d.ts +6 -0
- package/dist/interpreter/builtins/cd.d.ts +6 -0
- package/dist/interpreter/builtins/continue.d.ts +6 -0
- package/dist/interpreter/builtins/declare.d.ts +29 -0
- package/dist/interpreter/builtins/eval.d.ts +9 -0
- package/dist/interpreter/builtins/exit.d.ts +5 -0
- package/dist/interpreter/builtins/export.d.ts +13 -0
- package/dist/interpreter/builtins/index.d.ts +36 -0
- package/dist/interpreter/builtins/let.d.ts +18 -0
- package/dist/interpreter/builtins/local.d.ts +6 -0
- package/dist/interpreter/builtins/read.d.ts +6 -0
- package/dist/interpreter/builtins/return.d.ts +6 -0
- package/dist/interpreter/builtins/set.d.ts +6 -0
- package/dist/interpreter/builtins/shift.d.ts +12 -0
- package/dist/interpreter/builtins/source.d.ts +6 -0
- package/dist/interpreter/builtins/unset.d.ts +12 -0
- package/dist/interpreter/builtins/variable-helpers.d.ts +30 -0
- package/dist/interpreter/conditionals.d.ts +17 -0
- package/dist/interpreter/control-flow.d.ts +21 -0
- package/dist/interpreter/errors.d.ts +107 -0
- package/dist/interpreter/expansion/analysis.d.ts +39 -0
- package/dist/interpreter/expansion/brace-range.d.ts +20 -0
- package/dist/interpreter/expansion/pattern.d.ts +22 -0
- package/dist/interpreter/expansion/variable.d.ts +27 -0
- package/dist/interpreter/expansion/word-split.d.ts +24 -0
- package/dist/interpreter/expansion.d.ts +27 -0
- package/dist/interpreter/functions.d.ts +12 -0
- package/dist/interpreter/helpers/array.d.ts +23 -0
- package/dist/interpreter/helpers/condition.d.ts +22 -0
- package/dist/interpreter/helpers/errors.d.ts +8 -0
- package/dist/interpreter/helpers/file-tests.d.ts +33 -0
- package/dist/interpreter/helpers/ifs.d.ts +43 -0
- package/dist/interpreter/helpers/loop.d.ts +24 -0
- package/dist/interpreter/helpers/numeric-compare.d.ts +13 -0
- package/dist/interpreter/helpers/readonly.d.ts +21 -0
- package/dist/interpreter/helpers/regex.d.ts +8 -0
- package/dist/interpreter/helpers/result.d.ts +54 -0
- package/dist/interpreter/helpers/statements.d.ts +20 -0
- package/dist/interpreter/helpers/string-compare.d.ts +22 -0
- package/dist/interpreter/helpers/string-tests.d.ts +13 -0
- package/dist/interpreter/helpers/variable-tests.d.ts +9 -0
- package/dist/interpreter/helpers/word-parts.d.ts +22 -0
- package/dist/interpreter/index.d.ts +3 -0
- package/dist/interpreter/interpreter.d.ts +61 -0
- package/dist/interpreter/redirections.d.ts +14 -0
- package/dist/interpreter/types.d.ts +68 -0
- package/dist/limits.d.ts +26 -0
- package/dist/network/allow-list/shared.d.ts +45 -0
- package/dist/network/allow-list.d.ts +51 -0
- package/dist/network/fetch.d.ts +25 -0
- package/dist/network/index.d.ts +7 -0
- package/dist/network/types.d.ts +85 -0
- package/dist/overlay-fs/OverlayFs.d.ts +87 -0
- package/dist/overlay-fs/index.d.ts +1 -0
- package/dist/parser/arithmetic-parser.d.ts +25 -0
- package/dist/parser/command-parser.d.ts +10 -0
- package/dist/parser/compound-parser.d.ts +14 -0
- package/dist/parser/conditional-parser.d.ts +8 -0
- package/dist/parser/expansion-parser.d.ts +10 -0
- package/dist/parser/lexer.d.ts +135 -0
- package/dist/parser/parser.d.ts +92 -0
- package/dist/parser/types.d.ts +23 -0
- package/dist/parser/word-parser.d.ts +33 -0
- package/dist/sandbox/Command.d.ts +28 -0
- package/dist/sandbox/Sandbox.d.ts +60 -0
- package/dist/sandbox/index.d.ts +2 -0
- package/dist/types.d.ts +80 -0
- package/dist/utils/args.d.ts +55 -0
- package/dist/utils/file-reader.d.ts +64 -0
- package/dist/utils/glob.d.ts +25 -0
- package/package.json +103 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as l,b as r}from"./chunk-74CEPOFO.js";var d={name:"alias",summary:"define or display aliases",usage:"alias [name[=value] ...]",options:[" --help display this help and exit"]},o="BASH_ALIAS_",f={name:"alias",async execute(i,n){if(r(i))return l(d);if(i.length===0){let e="";for(let[a,t]of Object.entries(n.env))if(a.startsWith(o)){let s=a.slice(o.length);e+=`alias ${s}='${t}'
|
|
2
|
+
`}return{stdout:e,stderr:"",exitCode:0}}for(let e of i){let a=e.indexOf("=");if(a===-1){let t=o+e;return n.env[t]?{stdout:`alias ${e}='${n.env[t]}'
|
|
3
|
+
`,stderr:"",exitCode:0}:{stdout:"",stderr:`alias: ${e}: not found
|
|
4
|
+
`,exitCode:1}}else{let t=e.slice(0,a),s=e.slice(a+1);(s.startsWith("'")&&s.endsWith("'")||s.startsWith('"')&&s.endsWith('"'))&&(s=s.slice(1,-1)),n.env[o+t]=s}}return{stdout:"",stderr:"",exitCode:0}}},m={name:"unalias",async execute(i,n){if(r(i))return l({name:"unalias",summary:"remove alias definitions",usage:"unalias name [name ...]",options:["-a remove all aliases"," --help display this help and exit"]});if(i.length===0)return{stdout:"",stderr:`unalias: usage: unalias [-a] name [name ...]
|
|
5
|
+
`,exitCode:1};if(i[0]==="-a"){for(let t of Object.keys(n.env))t.startsWith(o)&&delete n.env[t];return{stdout:"",stderr:"",exitCode:0}}let e=!1,a="";for(let t of i){let s=o+t;n.env[s]?delete n.env[s]:(a+=`unalias: ${t}: not found
|
|
6
|
+
`,e=!0)}return{stdout:"",stderr:a,exitCode:e?1:0}}};export{f as aliasCommand,m as unaliasCommand};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{i as I}from"./chunk-JYYFSUWP.js";import{a as W,b as A,c as R}from"./chunk-74CEPOFO.js";function C(t,e,r){if(t.length<2)return e.RSTART=0,e.RLENGTH=-1,0;let i=String(r(t[0],e)),o=t[1].trim();o.startsWith("/")&&o.endsWith("/")&&(o=o.slice(1,-1));try{let n=new RegExp(o).exec(i);if(n)return e.RSTART=n.index+1,e.RLENGTH=n[0].length,e.RSTART}catch{}return e.RSTART=0,e.RLENGTH=-1,0}function O(t,e,r){if(t.length<3)return"";let i=String(r(t[0],e)),o=String(r(t[1],e)),f=String(r(t[2],e)),n=t.length>=4?String(r(t[3],e)):e.line;i.startsWith("/")&&i.endsWith("/")&&(i=i.slice(1,-1));try{let a=f.toLowerCase()==="g",s=a?0:parseInt(f,10)||1;if(a){let l=new RegExp(i,"g");return n.replace(l,(u,...d)=>T(o,u,d.slice(0,-2)))}else{let l=0,u=new RegExp(i,"g");return n.replace(u,(d,...c)=>(l++,l===s?T(o,d,c.slice(0,-2)):d))}}catch{return n}}function T(t,e,r){let i="",o=0;for(;o<t.length;)if(t[o]==="\\"&&o+1<t.length){let f=t[o+1];if(f==="&")i+="&",o+=2;else if(f==="0")i+=e,o+=2;else if(f>="1"&&f<="9"){let n=parseInt(f,10)-1;i+=r[n]||"",o+=2}else f==="n"?(i+=`
|
|
2
|
+
`,o+=2):f==="t"?(i+=" ",o+=2):(i+=f,o+=2)}else t[o]==="&"?(i+=e,o++):(i+=t[o],o++);return i}function B(t,e,r){return t.length===0?e.line.length:String(r(t[0],e)).length}function L(t,e,r){if(t.length<2)return"";let i=String(r(t[0],e)),o=Number(r(t[1],e))-1;if(t.length>=3){let f=Number(r(t[2],e));return i.substr(Math.max(0,o),f)}return i.substr(Math.max(0,o))}function G(t,e,r){if(t.length<2)return 0;let i=String(r(t[0],e)),o=String(r(t[1],e)),f=i.indexOf(o);return f===-1?0:f+1}function _(t,e,r){if(t.length<2)return 0;let i=String(r(t[0],e)),o=t[1].trim(),f=t.length>=3?String(r(t[2],e)):e.FS,n=i.split(f===" "?/\s+/:f);e.arrays[o]||(e.arrays[o]={}),e.arrays[o]={};for(let a=0;a<n.length;a++)e.arrays[o][String(a+1)]=n[a];return n.length}function P(t,e,r){if(t.length<2)return 0;let i=String(r(t[0],e)),o=String(r(t[1],e)),f=t.length>=3?t[2].trim():"$0",n;if(f==="$0")n=e.line;else if(f.startsWith("$")){let u=parseInt(f.slice(1),10)-1;n=e.fields[u]||""}else n=String(e.vars[f]??"");let a=new RegExp(i),s=n.replace(a,o),l=s!==n?1:0;if(f==="$0")e.line=s;else if(f.startsWith("$")){let u=parseInt(f.slice(1),10)-1;e.fields[u]=s}else e.vars[f]=s;return l}function V(t,e,r){if(t.length<2)return 0;let i=String(r(t[0],e)),o=String(r(t[1],e)),f=t.length>=3?t[2].trim():"$0",n;if(f==="$0")n=e.line;else if(f.startsWith("$")){let d=parseInt(f.slice(1),10)-1;n=e.fields[d]||""}else n=String(e.vars[f]??"");let a=new RegExp(i,"g"),s=n.match(a),l=s?s.length:0,u=n.replace(a,o);if(f==="$0")e.line=u;else if(f.startsWith("$")){let d=parseInt(f.slice(1),10)-1;e.fields[d]=u}else e.vars[f]=u;return l}function D(t,e,r){return t.length===0?"":String(r(t[0],e)).toLowerCase()}function H(t,e,r){return t.length===0?"":String(r(t[0],e)).toUpperCase()}function q(t,e,r){if(t.length===0)return"";let i=String(r(t[0],e)),o=t.slice(1),f=0,n="",a=0;for(;a<i.length;)if(i[a]==="%"&&a+1<i.length){let s=a+1;for(;s<i.length&&/[-+ #0]/.test(i[s]);)s++;for(;s<i.length&&/\d/.test(i[s]);)s++;if(i[s]===".")for(s++;s<i.length&&/\d/.test(i[s]);)s++;let l=i[s];if(l==="s"||l==="d"||l==="i"||l==="f"){let u=o[f]?r(o[f],e):"";n+=String(u),f++,a=s+1}else l==="%"?(n+="%",a=s+1):n+=i[a++]}else if(i[a]==="\\"&&a+1<i.length){let s=i[a+1];s==="n"?n+=`
|
|
3
|
+
`:s==="t"?n+=" ":s==="r"?n+="\r":n+=s,a+=2}else n+=i[a++];return n}function h(t,e){if(t=t.trim(),t.startsWith('"')&&t.endsWith('"'))return ee(t.slice(1,-1));let r=t.match(/^(\w+)\s*\((.*)\)$/);if(r){let s=r[1],l=r[2],u=x(l);switch(s){case"length":return B(u,e,h);case"substr":return L(u,e,h);case"index":return G(u,e,h);case"split":return _(u,e,h);case"sub":return P(u,e,h);case"gsub":return V(u,e,h);case"match":return C(u,e,h);case"gensub":return O(u,e,h);case"tolower":return D(u,e,h);case"toupper":return H(u,e,h);case"sprintf":return q(u,e,h);case"int":return Math.floor(Number(h(u[0]||"0",e)));case"sqrt":return Math.sqrt(Number(h(u[0]||"0",e)));case"sin":return Math.sin(Number(h(u[0]||"0",e)));case"cos":return Math.cos(Number(h(u[0]||"0",e)));case"log":return Math.log(Number(h(u[0]||"0",e)));case"exp":return Math.exp(Number(h(u[0]||"0",e)));case"atan2":{let d=Number(h(u[0]||"0",e)),c=Number(h(u[1]||"0",e));return Math.atan2(d,c)}case"rand":return e.random?e.random():Math.random();case"srand":{let d=u.length>0?Number(h(u[0],e)):Date.now();return e.vars._srand_seed=d,d}case"systime":case"mktime":case"strftime":throw new Error(`function '${s}()' is not implemented`);case"system":throw new Error("system() is not supported - shell execution not allowed in sandboxed environment");case"close":throw new Error("close() is not supported - file operations not allowed");case"fflush":throw new Error("fflush() is not supported - file operations not allowed");case"nextfile":throw new Error("nextfile is not supported - use 'next' instead")}if(e.functions?.[s])return ne(s,u,e)}let i=t.match(/^(\w+)\[(.+)\]$/);if(i){let s=i[1],l=i[2],u=String(h(l,e));return e.arrays[s]?e.arrays[s][u]??"":""}if(t.startsWith("$")){if(t.startsWith("$(")){let l=t.slice(2,-1),u=Number(h(l,e));return u===0?e.line:e.fields[u-1]||""}let s=t.match(/^\$(\d+)$/);if(s){let l=parseInt(s[1],10);return l===0?e.line:e.fields[l-1]||""}}if(t==="NR")return e.NR;if(t==="NF")return e.NF;if(t==="FNR")return e.FNR;if(t==="FS")return e.FS;if(t==="OFS")return e.OFS;if(t==="FILENAME")return e.FILENAME;if(t==="RSTART")return e.RSTART;if(t==="RLENGTH")return e.RLENGTH;if(e.vars[t]!==void 0)return e.vars[t];let o=t.match(/^(.+?)\s*\?\s*(.+?)\s*:\s*(.+)$/);if(o){let s=k(o[1].trim(),e);return h(s?o[2].trim():o[3].trim(),e)}let f=t.match(/^(.+?)\s*(\^|\*\*)\s*(.+)$/);if(f){let s=Number(h(f[1],e)),l=Number(h(f[3],e));return s**l}let n=t.match(/^(.+?)\s+([+\-*/%])\s+(.+)$/);if(n){let s=Number(h(n[1],e)),l=Number(h(n[3],e));switch(n[2]){case"+":return s+l;case"-":return s-l;case"*":return s*l;case"/":return l!==0?s/l:0;case"%":return s%l}}let a=t.match(/^([a-zA-Z_]\w*|\$\d+|\d+(?:\.\d+)?)\s*([+\-*/%])\s*(.+)$/);if(a){let s=Number(h(a[1],e)),l=Number(h(a[3],e));switch(a[2]){case"+":return s+l;case"-":return s-l;case"*":return s*l;case"/":return l!==0?s/l:0;case"%":return s%l}}return t.includes("$")||t.includes('"')?te(t,e):/^-?\d+(\.\d+)?$/.test(t)?parseFloat(t):/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(t)?"":t}function x(t){let e=[],r="",i=0,o=!1;for(let f=0;f<t.length;f++){let n=t[f];n==='"'&&t[f-1]!=="\\"?(o=!o,r+=n):!o&&n==="("?(i++,r+=n):!o&&n===")"?(i--,r+=n):!o&&n===","&&i===0?(e.push(r.trim()),r=""):r+=n}return r.trim()&&e.push(r.trim()),e}function ee(t){return t.replace(/\\n/g,`
|
|
4
|
+
`).replace(/\\t/g," ").replace(/\\r/g,"\r").replace(/\\\\/g,"\\")}function te(t,e){let r="",i=0;for(;i<t.length;){for(;i<t.length&&/\s/.test(t[i]);)i++;if(i>=t.length)break;if(t[i]==='"'){let o="";for(i++;i<t.length&&t[i]!=='"';)if(t[i]==="\\"&&i+1<t.length){let f=t[i+1];f==="n"?o+=`
|
|
5
|
+
`:f==="t"?o+=" ":f==="r"?o+="\r":o+=f,i+=2}else o+=t[i++];i++,r+=o}else if(t[i]==="$"){i++;let o="";for(;i<t.length&&/\d/.test(t[i]);)o+=t[i++];let f=parseInt(o,10);r+=f===0?e.line:e.fields[f-1]||""}else{let o="";for(;i<t.length&&!/[\s$"]/.test(t[i]);)o+=t[i++];o==="NR"?r+=e.NR:o==="NF"?r+=e.NF:e.vars[o]!==void 0?r+=e.vars[o]:r+=o}}return r}function k(t,e){if(t=t.trim(),t.includes("&&"))return U(t,"&&").every(l=>k(l,e));if(t.includes("||"))return U(t,"||").some(l=>k(l,e));if(t.startsWith("!"))return!k(t.slice(1).trim(),e);if(t.startsWith("(")&&t.endsWith(")"))return k(t.slice(1,-1),e);if(t.startsWith("/")&&t.endsWith("/"))return new RegExp(t.slice(1,-1)).test(e.line);let r=t.match(/^(.+)\s+in\s+(\w+)$/);if(r){let s=String(h(r[1].trim(),e)),l=r[2];return!!(e.arrays[l]&&e.arrays[l][s]!==void 0)}let i=t.match(/^NR\s*(==|!=|>|<|>=|<=)\s*(\d+)$/);if(i){let s=i[1],l=parseInt(i[2],10);return j(e.NR,s,l)}let o=t.match(/^\$(\d+)\s*~\s*\/([^/]+)\/$/);if(o){let s=parseInt(o[1],10),l=o[2],u=s===0?e.line:e.fields[s-1]||"";return new RegExp(l).test(u)}let f=t.match(/^\$(\d+)\s*!~\s*\/([^/]+)\/$/);if(f){let s=parseInt(f[1],10),l=f[2],u=s===0?e.line:e.fields[s-1]||"";return!new RegExp(l).test(u)}let n=t.match(/^(.+?)\s*(==|!=|>=|<=|>|<)\s*(.+)$/);if(n){let s=n[1].trim(),l=n[2],u=n[3].trim(),d=h(s,e),c=h(u,e);return j(d,l,c)}let a=h(t,e);return typeof a=="number"?a!==0:typeof a=="string"?a!=="":!!a}function U(t,e){let r=[],i="",o=0,f=!1;for(let n=0;n<t.length;n++){if(t[n]==='"'&&t[n-1]!=="\\"&&(f=!f),!f){if(t[n]==="(")o++;else if(t[n]===")")o--;else if(o===0&&t.slice(n,n+e.length)===e){r.push(i.trim()),i="",n+=e.length-1;continue}}i+=t[n]}return i.trim()&&r.push(i.trim()),r}function j(t,e,r){let i=typeof t=="number"?t:parseFloat(String(t)),o=typeof r=="number"?r:parseFloat(String(r));if(!Number.isNaN(i)&&!Number.isNaN(o))switch(e){case"==":return i===o;case"!=":return i!==o;case">":return i>o;case"<":return i<o;case">=":return i>=o;case"<=":return i<=o}else{let n=String(t),a=String(r);switch(e){case"==":return n===a;case"!=":return n!==a;case">":return n>a;case"<":return n<a;case">=":return n>=a;case"<=":return n<=a}}return!1}var X=100;function ne(t,e,r){let i=r.functions[t];if(!i)throw new Error(`awk: undefined function '${t}'`);let o="__func_depth__",f=r.vars[o]||0;if(f>=X)throw new Error(`awk: function '${t}' exceeded maximum recursion depth (${X})`);r.vars[o]=f+1;let n={};for(let s of i.params)n[s]=r.vars[s];for(let s=0;s<i.params.length;s++)s<e.length?r.vars[i.params[s]]=h(e[s],r):r.vars[i.params[s]]="";let a="";try{let s=i.body.match(/return\s+(.+)/);s&&(a=h(s[1].trim(),r))}finally{for(let s of i.params){let l=n[s];l!==void 0?r.vars[s]=l:delete r.vars[s]}r.vars[o]=f}return a}function z(t){let e={begin:null,main:[],end:null,functions:{}},r=t.trim(),i=/function\s+(\w+)\s*\(([^)]*)\)\s*\{/g;for(let n=i.exec(r);n!==null;n=i.exec(r)){let a=n[1],s=n[2],l=n.index,u=n.index+n[0].length-1,d=y(r,u);if(d!==-1){let c=s.split(",").map(g=>g.trim()).filter(g=>g.length>0),m=r.slice(u+1,d).trim();e.functions[a]={params:c,body:m},r=r.slice(0,l)+r.slice(d+1),r=r.trim(),i.lastIndex=0}}let o=r.match(/\bBEGIN\s*\{/);if(o&&o.index!==void 0){let n=o.index,a=r.slice(n+5).trim();if(a.startsWith("{")){let s=y(a,0);s!==-1&&(e.begin=a.slice(1,s).trim(),r=r.slice(0,n)+a.slice(s+1),r=r.trim())}}let f=r.match(/\bEND\s*\{/);if(f&&f.index!==void 0){let n=f.index,a=r.slice(n+3).trim();if(a.startsWith("{")){let s=y(a,0);s!==-1&&(e.end=a.slice(1,s).trim(),r=r.slice(0,n).trim())}}for(;r&&(r=r.trim(),!!r);){let n=!1;if(r.startsWith("{")){let a=y(r,0);a!==-1&&(e.main.push({pattern:null,action:r.slice(1,a).trim()}),r=r.slice(a+1).trim(),n=!0)}if(!n){let a=r.match(/^\/([^/]*)\/\s*,\s*\/([^/]*)\/\s*\{/);if(a){let s=r.indexOf("{"),l=y(r,s);l!==-1&&(e.main.push({pattern:null,range:{start:a[1],end:a[2]},action:r.slice(s+1,l).trim()}),r=r.slice(l+1).trim(),n=!0)}}if(!n){let a=r.match(/^\/([^/]*)\/\s*\{/);if(a){let s=r.indexOf("{"),l=y(r,s);l!==-1&&(e.main.push({pattern:a[1],action:r.slice(s+1,l).trim()}),r=r.slice(l+1).trim(),n=!0)}}if(!n){let a=r.match(/^\/([^/]*)\/\s*,\s*\/([^/]*)\//);a&&(e.main.push({pattern:null,range:{start:a[1],end:a[2]},action:"print"}),r=r.slice(a[0].length).trim(),n=!0)}if(!n){let a=r.match(/^\/([^/]*)\//);a&&(e.main.push({pattern:a[1],action:"print"}),r=r.slice(a[0].length).trim(),n=!0)}if(!n&&r.includes("{")){let a=r.indexOf("{"),s=y(r,a);s!==-1&&(e.main.push({pattern:r.slice(0,a).trim()||null,action:r.slice(a+1,s).trim()}),r=r.slice(s+1).trim(),n=!0)}n||(r.startsWith("print")||r.startsWith("printf")?(e.main.push({pattern:null,action:r}),r=""):(e.main.push({pattern:r,action:"print"}),r=""))}return e.main.length===0&&!e.begin&&!e.end&&e.main.push({pattern:null,action:"print"}),e}function y(t,e){if(t[e]!=="{")return-1;let r=1,i=!1,o="";for(let f=e+1;f<t.length;f++){let n=t[f],a=t[f-1];if(i)n===o&&a!=="\\"&&(i=!1);else if(n==='"'||n==="'")i=!0,o=n;else if(n==="{")r++;else if(n==="}"&&(r--,r===0))return f}return-1}var F=1e4;function v(t,e){let r="",i=re(t);for(let o of i)if(r+=M(o,e),e.shouldNext||e.shouldExit||e.loopBreak||e.loopContinue)break;return r}function re(t){let e=[],r="",i=0,o=0,f=!1;for(let n=0;n<t.length;n++){let a=t[n];if(a==='"'&&t[n-1]!=="\\"&&(f=!f),!f){if(a==="{")i++;else if(a==="}")i--;else if(a==="(")o++;else if(a===")")o--;else if((a===";"||a===`
|
|
6
|
+
`)&&i===0&&o===0){r.trim()&&e.push(r.trim()),r="";continue}}r+=a}return r.trim()&&e.push(r.trim()),e}function M(t,e){if(t=t.trim(),!t)return"";if(t.startsWith("if"))return ie(t,e);if(t.startsWith("while"))return se(t,e);if(t.startsWith("do"))return ae(t,e);if(t.startsWith("for"))return oe(t,e);if(t==="print"||t==="print $0")return`${e.line}
|
|
7
|
+
`;if(t.startsWith("print ")){let n=t.slice(6).trim();return`${le(n,e)}
|
|
8
|
+
`}if(t.startsWith("printf ")){let n=t.slice(7).trim();return fe(n,e)}if(t==="next")return e.shouldNext=!0,"";if(t==="exit"||t.startsWith("exit ")){if(e.shouldExit=!0,t.startsWith("exit ")){let n=t.slice(5).trim();e.exitCode=Number(h(n,e))||0}else e.exitCode=0;return""}if(t==="break")return e.loopBreak=!0,"";if(t==="continue")return e.loopContinue=!0,"";if(t==="getline"||t.startsWith("getline "))return ue(t,e);let r=t.match(/^delete\s+(\w+)\[(.+)\]$/);if(r){let n=r[1],a=r[2],s=String(h(a,e));return e.arrays[n]&&delete e.arrays[n][s],""}let i=t.match(/^(\w+)\[(.+)\]\s*=\s*(.+)$/);if(i){let n=i[1],a=i[2],s=i[3];e.arrays[n]||(e.arrays[n]={});let l=String(h(a,e)),u=h(s,e);return e.arrays[n][l]=u,""}if(t.match(/^(\w+)\+\+$/)){let n=t.slice(0,-2),a=Number(e.vars[n])||0;return e.vars[n]=a+1,""}if(t.match(/^(\w+)--$/)){let n=t.slice(0,-2),a=Number(e.vars[n])||0;return e.vars[n]=a-1,""}if(t.match(/^\+\+(\w+)$/)){let n=t.slice(2),a=Number(e.vars[n])||0;return e.vars[n]=a+1,""}if(t.match(/^--(\w+)$/)){let n=t.slice(2),a=Number(e.vars[n])||0;return e.vars[n]=a-1,""}let o=t.match(/^(\w+)\[(.+)\]\+\+$/);if(o){let n=o[1],a=o[2];e.arrays[n]||(e.arrays[n]={});let s=String(h(a,e)),l=Number(e.arrays[n][s])||0;return e.arrays[n][s]=l+1,""}if(t.includes("+=")){let n=t.indexOf("+="),a=t.slice(0,n).trim(),s=t.slice(n+2).trim(),l=Number(h(s,e))||0,u=a.match(/^(\w+)\[(.+)\]$/);if(u){let d=u[1],c=u[2];e.arrays[d]||(e.arrays[d]={});let m=String(h(c,e)),g=Number(e.arrays[d][m])||0;e.arrays[d][m]=g+l}else{let d=Number(e.vars[a])||0;e.vars[a]=d+l}return""}if(t.includes("-=")){let n=t.indexOf("-="),a=t.slice(0,n).trim(),s=t.slice(n+2).trim(),l=Number(e.vars[a])||0,u=Number(h(s,e))||0;return e.vars[a]=l-u,""}if(t.includes("*=")){let n=t.indexOf("*="),a=t.slice(0,n).trim(),s=t.slice(n+2).trim(),l=Number(e.vars[a])||0,u=Number(h(s,e))||0;return e.vars[a]=l*u,""}if(t.includes("/=")){let n=t.indexOf("/="),a=t.slice(0,n).trim(),s=t.slice(n+2).trim(),l=Number(e.vars[a])||0,u=Number(h(s,e))||0;return e.vars[a]=u!==0?l/u:0,""}if(t.includes("=")&&!t.includes("==")&&!t.includes("!=")&&!t.includes(">=")&&!t.includes("<=")){let n=t.indexOf("="),a=t.slice(0,n).trim(),s=t.slice(n+1).trim();return e.vars[a]=h(s,e),""}return t.match(/^(\w+)\s*\((.+)\)$/)&&h(t,e),""}function ie(t,e){let r=t.indexOf("(");if(r===-1)return"";let i=1,o=r+1;for(;o<t.length&&i>0;)t[o]==="("?i++:t[o]===")"&&i--,o++;o--;let f=t.slice(r+1,o).trim(),n=t.slice(o+1).trim(),a,s=null,l;if(n.startsWith("{")){let u=y(n,0);a=n.slice(1,u).trim(),l=n.slice(u+1).trim()}else{let u=n.indexOf(";");if(u!==-1)a=n.slice(0,u).trim(),l=n.slice(u+1).trim();else{let d=n.indexOf(" else ");d!==-1?(a=n.slice(0,d).trim(),l=n.slice(d+1).trim()):(a=n,l="")}}if(l.startsWith("else")){let u=l.slice(4).trim();if(u.startsWith("{")){let d=y(u,0);s=u.slice(1,d).trim()}else if(u.startsWith("if"))s=u;else{let d=u.indexOf(";");s=d!==-1?u.slice(0,d).trim():u}}return k(f,e)?v(a,e):s?v(s,e):""}function se(t,e){let r=t.indexOf("(");if(r===-1)return"";let i=1,o=r+1;for(;o<t.length&&i>0;)t[o]==="("?i++:t[o]===")"&&i--,o++;o--;let f=t.slice(r+1,o).trim(),n=t.slice(o+1).trim(),a;if(n.startsWith("{")){let d=y(n,0);a=n.slice(1,d).trim()}else a=n;let s="",l=0,u=e.maxIterations??F;for(;k(f,e);){if(l++,l>u)throw new I(`awk: while loop exceeded maximum iterations (${u})`,"iterations",s);if(e.loopContinue=!1,s+=v(a,e),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext)break}return s}function ae(t,e){if(!t.match(/^do\s*\{/))return"";let i=t.indexOf("{"),o=y(t,i);if(o===-1)return"";let f=t.slice(i+1,o).trim(),a=t.slice(o+1).trim().match(/^while\s*\((.+)\)\s*;?$/);if(!a)return"";let s=a[1].trim(),l="",u=0,d=e.maxIterations??F;do{if(u++,u>d)throw new I(`awk: do-while loop exceeded maximum iterations (${d})`,"iterations",l);if(e.loopContinue=!1,l+=v(f,e),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext)break}while(k(s,e));return l}function oe(t,e){let r=t.indexOf("(");if(r===-1)return"";let i=1,o=r+1;for(;o<t.length&&i>0;)t[o]==="("?i++:t[o]===")"&&i--,o++;o--;let f=t.slice(r+1,o).trim(),n=t.slice(o+1).trim(),a;if(n.startsWith("{")){let p=y(n,0);a=n.slice(1,p).trim()}else a=n;let s=f.match(/^(\w+)\s+in\s+(\w+)$/);if(s){let p=s[1],w=s[2],b="";if(e.arrays[w])for(let S of Object.keys(e.arrays[w])){if(e.vars[p]=S,e.loopContinue=!1,b+=v(a,e),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext)break}return b}let l=f.split(";").map(p=>p.trim());if(l.length!==3)return"";let[u,d,c]=l;u&&M(u,e);let m="",g=0,N=e.maxIterations??F;for(;!d||k(d,e);){if(g++,g>N)throw new I(`awk: for loop exceeded maximum iterations (${N})`,"iterations",m);if(e.loopContinue=!1,m+=v(a,e),e.loopBreak){e.loopBreak=!1;break}if(e.shouldExit||e.shouldNext)break;c&&M(c,e)}return m}function le(t,e){let r=[],i=Z(t);for(let o of i)r.push(String(h(o.trim(),e)));return r.join(e.OFS)}function Z(t){let e=[],r="",i=!1,o=0;for(let f=0;f<t.length;f++){let n=t[f];n==='"'&&t[f-1]!=="\\"?(i=!i,r+=n):n==="("&&!i?(o++,r+=n):n===")"&&!i?(o--,r+=n):n===","&&!i&&o===0?(e.push(r),r=""):r+=n}return r&&e.push(r),e}function fe(t,e){let r=t.match(/^"([^"]*)"(.*)$/);if(!r)return"";let i=r[1],o=r[2].trim(),f=o?Z(o.replace(/^,\s*/,"")):[],n=0,a="",s=0;for(;s<i.length;)if(i[s]==="%"&&s+1<i.length){let l=s+1,u="",d="";for(;l<i.length&&/[-+ #0]/.test(i[l]);)l++;for(;l<i.length&&/\d/.test(i[l]);)u+=i[l++];if(i[l]===".")for(l++;l<i.length&&/\d/.test(i[l]);)d+=i[l++];let c=i[l];if(c==="s"){let m=f[n]?String(h(f[n],e)):"";u&&(m=m.padStart(parseInt(u,10))),a+=m,n++,s=l+1}else if(c==="d"||c==="i"){let m=f[n]?Math.floor(Number(h(f[n],e))):0,g=String(m);u&&(g=g.padStart(parseInt(u,10))),a+=g,n++,s=l+1}else if(c==="f"){let m=f[n]?Number(h(f[n],e)):0,g=d?parseInt(d,10):6,N=m.toFixed(g);u&&(N=N.padStart(parseInt(u,10))),a+=N,n++,s=l+1}else if(c==="x"||c==="X"){let m=f[n]?Math.floor(Number(h(f[n],e))):0,g=Math.abs(m).toString(16);c==="X"&&(g=g.toUpperCase()),u&&(g=g.padStart(parseInt(u,10),"0")),a+=m<0?`-${g}`:g,n++,s=l+1}else if(c==="o"){let m=f[n]?Math.floor(Number(h(f[n],e))):0,g=Math.abs(m).toString(8);u&&(g=g.padStart(parseInt(u,10),"0")),a+=m<0?`-${g}`:g,n++,s=l+1}else if(c==="c"){let m=f[n]?h(f[n],e):"";typeof m=="number"?a+=String.fromCharCode(m):a+=String(m).charAt(0)||"",n++,s=l+1}else if(c==="e"||c==="E"){let m=f[n]?Number(h(f[n],e)):0,g=d?parseInt(d,10):6,N=m.toExponential(g);c==="E"&&(N=N.toUpperCase()),u&&(N=N.padStart(parseInt(u,10))),a+=N,n++,s=l+1}else if(c==="g"||c==="G"){let m=f[n]?Number(h(f[n],e)):0,g=d?parseInt(d,10):6,N=Math.floor(Math.log10(Math.abs(m))),p;m===0?p="0":N<-4||N>=g?(p=m.toExponential(g-1),c==="G"&&(p=p.toUpperCase())):p=m.toPrecision(g),p=p.replace(/\.?0+$/,"").replace(/\.?0+e/,"e"),u&&(p=p.padStart(parseInt(u,10))),a+=p,n++,s=l+1}else c==="%"?(a+="%",s=l+1):a+=i[s++]}else if(i[s]==="\\"&&s+1<i.length){let l=i[s+1];l==="n"?a+=`
|
|
9
|
+
`:l==="t"?a+=" ":l==="r"?a+="\r":a+=l,s+=2}else a+=i[s++];return a}function ue(t,e){if(!e.lines||e.lineIndex===void 0)return"";let r=e.lineIndex+1;if(r>=e.lines.length)return"";let i=e.lines[r];if(t==="getline")e.line=i,e.fields=e.fieldSep?i.split(e.fieldSep):i.split(/\s+/),e.NF=e.fields.length,e.NR++,e.lineIndex=r;else{let o=t.slice(8).trim();o&&!o.startsWith("<")&&(e.vars[o]=i,e.NR++,e.lineIndex=r)}return""}function K(t,e){if(t===null)return!0;if(t.startsWith("/")&&t.endsWith("/"))return new RegExp(t.slice(1,-1)).test(e.line);if(/^(NR|NF|\$\d+)\s*(==|!=|>|<|>=|<=|~)/.test(t)||/\s*(==|!=|>|<|>=|<=)\s*/.test(t))return k(t,e);try{return new RegExp(t).test(e.line)}catch{return k(t,e)}}var ce={name:"awk",summary:"pattern scanning and text processing language",usage:"awk [OPTIONS] 'PROGRAM' [FILE...]",options:["-F FS use FS as field separator","-v VAR=VAL assign VAL to variable VAR"," --help display this help and exit"]},ve={name:"awk",async execute(t,e){if(A(t))return W(ce);let r=/\s+/,i=" ",o={},f=0;for(let p=0;p<t.length;p++){let w=t[p];if(w==="-F"&&p+1<t.length)i=Q(t[++p]),r=J(i),f=p+1;else if(w.startsWith("-F"))i=Q(w.slice(2)),r=J(i),f=p+1;else if(w==="-v"&&p+1<t.length){let b=t[++p],S=b.indexOf("=");if(S>0){let $=b.slice(0,S),E=b.slice(S+1);o[$]=E}f=p+1}else{if(w.startsWith("--"))return R("awk",w);if(w.startsWith("-")&&w.length>1){let b=w[1];if(b!=="F"&&b!=="v")return R("awk",`-${b}`);f=p+1}else if(!w.startsWith("-")){f=p;break}}}if(f>=t.length)return{stdout:"",stderr:`awk: missing program
|
|
10
|
+
`,exitCode:1};let n=t[f],a=t.slice(f+1),{begin:s,main:l,end:u,functions:d}=z(n),c={FS:i,OFS:" ",NR:0,NF:0,FNR:0,FILENAME:"",RSTART:0,RLENGTH:-1,fields:[],line:"",vars:o,arrays:{},functions:d||{},fieldSep:r,maxIterations:e.limits?.maxAwkIterations},m="";if(s&&(m+=v(s,c),c.shouldExit))return{stdout:m,stderr:"",exitCode:c.exitCode||0};let g=[];if(a.length>0)for(let p of a)try{let w=e.fs.resolvePath(e.cwd,p),S=(await e.fs.readFile(w)).split(`
|
|
11
|
+
`);S.length>0&&S[S.length-1]===""&&S.pop(),g.push({filename:p,lines:S})}catch{return{stdout:"",stderr:`awk: ${p}: No such file or directory
|
|
12
|
+
`,exitCode:1}}else{let p=e.stdin.split(`
|
|
13
|
+
`);p.length>0&&p[p.length-1]===""&&p.pop(),g.push({filename:"",lines:p})}let N=l.map(()=>!1);for(let p of g){for(c.FILENAME=p.filename,c.FNR=0,c.lines=p.lines,c.lineIndex=-1;c.lineIndex<p.lines.length-1;){c.lineIndex++;let w=p.lines[c.lineIndex];c.NR++,c.FNR++,c.line=w,c.fields=w.split(r),c.NF=c.fields.length,c.shouldNext=!1;for(let b=0;b<l.length&&!(c.shouldExit||c.shouldNext);b++){let S=l[b];if(S.range){let $=new RegExp(S.range.start),E=new RegExp(S.range.end);N[b]?(m+=v(S.action,c),E.test(w)&&(N[b]=!1)):$.test(w)&&(N[b]=!0,m+=v(S.action,c),E.test(w)&&(N[b]=!1))}else K(S.pattern,c)&&(m+=v(S.action,c))}if(c.shouldExit)break}if(c.shouldExit)break}return u&&!c.shouldExit&&(m+=v(u,c)),{stdout:m,stderr:"",exitCode:c.exitCode||0}}};function Q(t){return t.replace(/\\t/g," ").replace(/\\n/g,`
|
|
14
|
+
`).replace(/\\r/g,"\r").replace(/\\\\/g,"\\")}function J(t){if(t===" ")return/\s+/;if(/[[\](){}.*+?^$|\\]/.test(t))try{return new RegExp(t)}catch{return new RegExp(Y(t))}return new RegExp(Y(t))}function Y(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}export{ve as awkCommand};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{b as p}from"./chunk-3YNHMZ5M.js";import{a as l}from"./chunk-ZVV5VXYZ.js";import{a as c,b as i}from"./chunk-74CEPOFO.js";var b={name:"base64",summary:"base64 encode/decode data and print to standard output",usage:"base64 [OPTION]... [FILE]",options:["-d, --decode decode data","-w, --wrap=COLS wrap encoded lines after COLS character (default 76, 0 to disable)"," --help display this help and exit"]},g={decode:{short:"d",long:"decode",type:"boolean"},wrap:{short:"w",long:"wrap",type:"number",default:76}},x={name:"base64",async execute(d,u){if(i(d))return c(b);let e=l("base64",d,g);if(!e.ok)return e.error;let f=e.result.flags.decode,s=e.result.flags.wrap,m=e.result.positional,a=await p(u,m,{cmdName:"base64"});if(!a.ok)return a.error;let n=a.content;try{if(f){let r=n.replace(/\s/g,"");return{stdout:Buffer.from(r,"base64").toString("utf-8"),stderr:"",exitCode:0}}let t=Buffer.from(n).toString("base64");if(s>0){let r=[];for(let o=0;o<t.length;o+=s)r.push(t.slice(o,o+s));t=r.join(`
|
|
2
|
+
`)+(t.length>0?`
|
|
3
|
+
`:"")}return{stdout:t,stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`base64: invalid input
|
|
4
|
+
`,exitCode:1}}}};export{x as base64Command};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as r,b as m}from"./chunk-74CEPOFO.js";var p={name:"basename",summary:"strip directory and suffix from filenames",usage:`basename NAME [SUFFIX]
|
|
2
|
+
basename OPTION... NAME...`,options:["-a, --multiple support multiple arguments","-s, --suffix=SUFFIX remove a trailing SUFFIX"," --help display this help and exit"]},c={name:"basename",async execute(n,u){if(m(n))return r(p);let i=!1,s="",a=[];for(let t=0;t<n.length;t++){let e=n[t];e==="-a"||e==="--multiple"?i=!0:e==="-s"&&t+1<n.length?(s=n[++t],i=!0):e.startsWith("--suffix=")?(s=e.slice(9),i=!0):e.startsWith("-")||a.push(e)}if(a.length===0)return{stdout:"",stderr:`basename: missing operand
|
|
3
|
+
`,exitCode:1};!i&&a.length>=2&&(s=a.pop()??"");let o=[];for(let t of a){let e=t.replace(/\/+$/,""),l=e.split("/").pop()||e;s&&l.endsWith(s)&&(l=l.slice(0,-s.length)),o.push(l)}return{stdout:`${o.join(`
|
|
4
|
+
`)}
|
|
5
|
+
`,stderr:"",exitCode:0}}};export{c as basenameCommand};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as l,b as u}from"./chunk-74CEPOFO.js";var m={name:"bash",summary:"execute shell commands or scripts",usage:"bash [OPTIONS] [SCRIPT_FILE] [ARGUMENTS...]",options:["-c COMMAND execute COMMAND string"," --help display this help and exit"],notes:["Without -c, reads and executes commands from SCRIPT_FILE.","Arguments are passed as $1, $2, etc. to the script.",'$0 is set to the script name (or "bash" with -c).']},b={name:"bash",async execute(t,e){if(u(t))return l(m);if(t[0]==="-c"&&t.length>=2){let o=t[1],s=t[2]||"bash",i=t.slice(3);return h(o,s,i,e)}if(t.length===0)return{stdout:"",stderr:"",exitCode:0};let n=t[0],r=t.slice(1);try{let o=e.fs.resolvePath(e.cwd,n),s=await e.fs.readFile(o);return h(s,n,r,e)}catch{return{stdout:"",stderr:`bash: ${n}: No such file or directory
|
|
2
|
+
`,exitCode:127}}}},x={name:"sh",async execute(t,e){if(u(t))return l({...m,name:"sh",summary:"execute shell commands or scripts (POSIX shell)"});if(t[0]==="-c"&&t.length>=2){let o=t[1],s=t[2]||"sh",i=t.slice(3);return h(o,s,i,e)}if(t.length===0)return{stdout:"",stderr:"",exitCode:0};let n=t[0],r=t.slice(1);try{let o=e.fs.resolvePath(e.cwd,n),s=await e.fs.readFile(o);return h(s,n,r,e)}catch{return{stdout:"",stderr:`sh: ${n}: No such file or directory
|
|
3
|
+
`,exitCode:127}}}};async function h(t,e,n,r){if(!r.exec)return{stdout:"",stderr:`bash: internal error: exec function not available
|
|
4
|
+
`,exitCode:1};let o={0:e,"#":String(n.length),"@":n.join(" "),"*":n.join(" ")};n.forEach((c,a)=>{o[String(a+1)]=c});let s=t;if(s.startsWith("#!")){let c=s.indexOf(`
|
|
5
|
+
`);c!==-1&&(s=s.slice(c+1))}let i=s.split(`
|
|
6
|
+
`),d=[];for(let c of i){let a=c.trim();a&&!a.startsWith("#")&&d.push(a)}let f=d.join("; ");return await r.exec(f,{env:o})}export{b as bashCommand,x as shCommand};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as p}from"./chunk-3YNHMZ5M.js";import{a as d}from"./chunk-ZVV5VXYZ.js";import{a as c,b as m}from"./chunk-74CEPOFO.js";var f={name:"cat",summary:"concatenate files and print on the standard output",usage:"cat [OPTION]... [FILE]...",options:["-n, --number number all output lines"," --help display this help and exit"]},b={number:{short:"n",long:"number",type:"boolean"}},w={name:"cat",async execute(t,r){if(m(t))return c(f);let e=d("cat",t,b);if(!e.ok)return e.error;let s=e.result.flags.number,o=e.result.positional,a=await p(r,o,{cmdName:"cat",allowStdinMarker:!0,stopOnError:!1}),n="",i=1;for(let{content:l}of a.files)if(s){let u=h(l,i);n+=u.content,i=u.nextLineNumber}else n+=l;return{stdout:n,stderr:a.stderr,exitCode:a.exitCode}}};function h(t,r){let e=t.split(`
|
|
2
|
+
`),s=t.endsWith(`
|
|
3
|
+
`),o=s?e.slice(0,-1):e;return{content:o.map((n,i)=>`${String(r+i).padStart(6," ")} ${n}`).join(`
|
|
4
|
+
`)+(s?`
|
|
5
|
+
`:""),nextLineNumber:r+o.length}}export{w as catCommand};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{a as h,b as m}from"./chunk-74CEPOFO.js";var v={name:"chmod",summary:"change file mode bits",usage:"chmod [OPTIONS] MODE FILE...",options:["-R change files recursively","-v output a diagnostic for every file processed"," --help display this help and exit"]},C={name:"chmod",async execute(o,s){if(m(o))return h(v);if(o.length<2)return{stdout:"",stderr:`chmod: missing operand
|
|
2
|
+
`,exitCode:1};let r=!1,n=!1,e=0;for(;e<o.length&&o[e].startsWith("-");){let t=o[e];if(t==="-R"||t==="--recursive")r=!0,e++;else if(t==="-v"||t==="--verbose")n=!0,e++;else if(t==="--"){e++;break}else{if(/^[+-]?[rwxugo]+/.test(t)||/^\d+$/.test(t))break;if(/^-[Rv]+$/.test(t)){t.includes("R")&&(r=!0),t.includes("v")&&(n=!0),e++;continue}return{stdout:"",stderr:`chmod: invalid option -- '${t.slice(1)}'
|
|
3
|
+
`,exitCode:1}}}if(o.length-e<2)return{stdout:"",stderr:`chmod: missing operand
|
|
4
|
+
`,exitCode:1};let a=o[e],f=o.slice(e+1),i;try{i=$(a)}catch{return{stdout:"",stderr:`chmod: invalid mode: '${a}'
|
|
5
|
+
`,exitCode:1}}let c="",d="",l=!1;for(let t of f){let u=s.fs.resolvePath(s.cwd,t);try{if(await s.fs.chmod(u,i),n&&(c+=`mode of '${t}' changed to ${i.toString(8).padStart(4,"0")}
|
|
6
|
+
`),r&&(await s.fs.stat(u)).isDirectory){let w=await p(s,u,i,n);c+=w}}catch{d+=`chmod: cannot access '${t}': No such file or directory
|
|
7
|
+
`,l=!0}}return{stdout:c,stderr:d,exitCode:l?1:0}}};async function p(o,s,r,n){let e="",a=await o.fs.readdir(s);for(let f of a){let i=s==="/"?`/${f}`:`${s}/${f}`;await o.fs.chmod(i,r),n&&(e+=`mode of '${i}' changed to ${r.toString(8).padStart(4,"0")}
|
|
8
|
+
`),(await o.fs.stat(i)).isDirectory&&(e+=await p(o,i,r,n))}return e}function $(o){if(/^[0-7]+$/.test(o))return parseInt(o,8);let s=420,r=o.split(",");for(let n of r){let e=n.match(/^([ugoa]*)([+\-=])([rwxXst]*)$/);if(!e)throw new Error(`Invalid mode: ${o}`);let a=e[1]||"a",f=e[2],i=e[3];(a==="a"||a==="")&&(a="ugo");let c=0;i.includes("r")&&(c|=4),i.includes("w")&&(c|=2),(i.includes("x")||i.includes("X"))&&(c|=1);for(let d of a){let l=0;d==="u"?l=6:d==="g"?l=3:d==="o"&&(l=0);let t=c<<l;f==="+"?s|=t:f==="-"?s&=~t:f==="="&&(s&=~(7<<l),s|=t)}}return s}export{C as chmodCommand};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
async function u(e,n,s){let{cmdName:t,allowStdinMarker:f=!0,stopOnError:i=!1}=s;if(n.length===0)return{files:[{filename:"",content:e.stdin}],stderr:"",exitCode:0};let r=[],a="",c=0;for(let o of n){if(f&&o==="-"){r.push({filename:"-",content:e.stdin});continue}try{let l=e.fs.resolvePath(e.cwd,o),d=await e.fs.readFile(l);r.push({filename:o,content:d})}catch{if(a+=`${t}: ${o}: No such file or directory
|
|
2
|
+
`,c=1,i)return{files:r,stderr:a,exitCode:c}}}return{files:r,stderr:a,exitCode:c}}async function h(e,n,s){let t=await u(e,n,{...s,stopOnError:!0});return t.exitCode!==0?{ok:!1,error:{stdout:"",stderr:t.stderr,exitCode:t.exitCode}}:{ok:!0,content:t.files.map(i=>i.content).join("")}}export{u as a,h as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function n(e){return e instanceof Error?e.message:String(e)}export{n as a};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function s(t){let e=`${t.name} - ${t.summary}
|
|
2
|
+
|
|
3
|
+
`;if(e+=`Usage: ${t.usage}
|
|
4
|
+
`,t.description){if(e+=`
|
|
5
|
+
Description:
|
|
6
|
+
`,typeof t.description=="string")for(let n of t.description.split(`
|
|
7
|
+
`))e+=n?` ${n}
|
|
8
|
+
`:`
|
|
9
|
+
`;else if(t.description.length>0)for(let n of t.description)e+=n?` ${n}
|
|
10
|
+
`:`
|
|
11
|
+
`}if(t.options&&t.options.length>0){e+=`
|
|
12
|
+
Options:
|
|
13
|
+
`;for(let n of t.options)e+=` ${n}
|
|
14
|
+
`}if(t.examples&&t.examples.length>0){e+=`
|
|
15
|
+
Examples:
|
|
16
|
+
`;for(let n of t.examples)e+=` ${n}
|
|
17
|
+
`}if(t.notes&&t.notes.length>0){e+=`
|
|
18
|
+
Notes:
|
|
19
|
+
`;for(let n of t.notes)e+=` ${n}
|
|
20
|
+
`}return{stdout:e,stderr:"",exitCode:0}}function o(t){return t.includes("--help")}function r(t,e){return{stdout:"",stderr:e.startsWith("--")?`${t}: unrecognized option '${e}'
|
|
21
|
+
`:`${t}: invalid option -- '${e.replace(/^-/,"")}'
|
|
22
|
+
`,exitCode:1}}export{s as a,o as b,r as c};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
var n=class extends Error{stdout;stderr;constructor(t,s="",e=""){super(t),this.stdout=s,this.stderr=e}prependOutput(t,s){this.stdout=t+this.stdout,this.stderr=s+this.stderr}},o=class extends n{levels;name="BreakError";constructor(t=1,s="",e=""){super("break",s,e),this.levels=t}},i=class extends n{levels;name="ContinueError";constructor(t=1,s="",e=""){super("continue",s,e),this.levels=t}},c=class extends n{exitCode;name="ReturnError";constructor(t=0,s="",e=""){super("return",s,e),this.exitCode=t}},a=class extends n{exitCode;name="ErrexitError";constructor(t,s="",e=""){super(`errexit: command exited with status ${t}`,s,e),this.exitCode=t}},d=class extends n{varName;name="NounsetError";constructor(t,s=""){super(`${t}: unbound variable`,s,`bash: ${t}: unbound variable
|
|
2
|
+
`),this.varName=t}},x=class extends n{exitCode;name="ExitError";constructor(t,s="",e=""){super("exit",s,e),this.exitCode=t}},p=class extends n{name="ArithmeticError";constructor(t,s="",e=""){super(t,s,e),this.stderr=e||`bash: ${t}
|
|
3
|
+
`}},h=class extends n{name="BadSubstitutionError";constructor(t,s="",e=""){super(t,s,e),this.stderr=e||`bash: ${t}: bad substitution
|
|
4
|
+
`}},l=class extends n{limitType;name="ExecutionLimitError";static EXIT_CODE=126;constructor(t,s,e="",u=""){super(t,e,u),this.limitType=s,this.stderr=u||`bash: ${t}
|
|
5
|
+
`}};function b(r){return r instanceof o||r instanceof i||r instanceof c}export{o as a,i as b,c,a as d,d as e,x as f,p as g,h,l as i,b as j};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var c=new Map;function f(l,o,t){let s=typeof t=="boolean"?{ignoreCase:t}:t??{},e=o;s.stripQuotes&&(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1));let i=s.ignoreCase?`i:${e}`:e,n=c.get(i);return n||(n=g(e,s.ignoreCase),c.set(i,n)),n.test(l)}function g(l,o){let t="^";for(let s=0;s<l.length;s++){let e=l[s];if(e==="*")t+=".*";else if(e==="?")t+=".";else if(e==="["){let i=s+1;for(;i<l.length&&l[i]!=="]";)i++;t+=l.slice(s,i+1),s=i}else e==="."||e==="+"||e==="^"||e==="$"||e==="{"||e==="}"||e==="("||e===")"||e==="|"||e==="\\"?t+=`\\${e}`:t+=e}return t+="$",new RegExp(t,o?"i":"")}export{f as a};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{c as d}from"./chunk-74CEPOFO.js";function w(t,r){let i=10,s=null,o=!1,l=!1,n=!1,u=[];for(let f=0;f<t.length;f++){let e=t[f];if(e==="-n"&&f+1<t.length){let a=t[++f];r==="tail"&&a.startsWith("+")?(n=!0,i=parseInt(a.slice(1),10)):i=parseInt(a,10)}else if(r==="tail"&&e.startsWith("-n+"))n=!0,i=parseInt(e.slice(3),10);else if(e.startsWith("-n"))i=parseInt(e.slice(2),10);else if(e==="-c"&&f+1<t.length)s=parseInt(t[++f],10);else if(e.startsWith("-c"))s=parseInt(e.slice(2),10);else if(e.startsWith("--bytes="))s=parseInt(e.slice(8),10);else if(e.startsWith("--lines="))i=parseInt(e.slice(8),10);else if(e==="-q"||e==="--quiet"||e==="--silent")o=!0;else if(e==="-v"||e==="--verbose")l=!0;else if(e.match(/^-\d+$/))i=parseInt(e.slice(1),10);else{if(e.startsWith("--"))return{ok:!1,error:d(r,e)};if(e.startsWith("-")&&e!=="-")return{ok:!1,error:d(r,e)};u.push(e)}}return s!==null&&(Number.isNaN(s)||s<0)?{ok:!1,error:{stdout:"",stderr:`${r}: invalid number of bytes
|
|
2
|
+
`,exitCode:1}}:Number.isNaN(i)||i<0?{ok:!1,error:{stdout:"",stderr:`${r}: invalid number of lines
|
|
3
|
+
`,exitCode:1}}:{ok:!0,options:{lines:i,bytes:s,quiet:o,verbose:l,files:u,fromLine:n}}}async function I(t,r,i,s){let{quiet:o,verbose:l,files:n}=r;if(n.length===0)return{stdout:s(t.stdin),stderr:"",exitCode:0};let u="",f="",e=0,a=l||!o&&n.length>1;for(let h=0;h<n.length;h++){let p=n[h];a&&(h>0&&(u+=`
|
|
4
|
+
`),u+=`==> ${p} <==
|
|
5
|
+
`);try{let c=t.fs.resolvePath(t.cwd,p),b=await t.fs.readFile(c);u+=s(b)}catch{f+=`${i}: ${p}: No such file or directory
|
|
6
|
+
`,e=1}}return{stdout:u,stderr:f,exitCode:e}}function W(t,r,i){if(i!==null)return t.slice(0,i);if(r===0)return"";let s=0,o=0,l=t.length;for(;s<l&&o<r;){let n=t.indexOf(`
|
|
7
|
+
`,s);if(n===-1)return`${t}
|
|
8
|
+
`;o++,s=n+1}return s>0?t.slice(0,s):""}function $(t,r,i,s){if(i!==null)return t.slice(-i);let o=t.length;if(o===0)return"";if(s){let f=0,e=1;for(;f<o&&e<r;){let h=t.indexOf(`
|
|
9
|
+
`,f);if(h===-1)break;e++,f=h+1}let a=t.slice(f);return a.endsWith(`
|
|
10
|
+
`)?a:`${a}
|
|
11
|
+
`}if(r===0)return"";let l=o-1;t[l]===`
|
|
12
|
+
`&&l--;let n=0;for(;l>=0&&n<r;){if(t[l]===`
|
|
13
|
+
`&&(n++,n===r)){l++;break}l--}l<0&&(l=0);let u=t.slice(l);return t[o-1]===`
|
|
14
|
+
`?u:`${u}
|
|
15
|
+
`}export{w as a,I as b,W as c,$ as d};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{c as p}from"./chunk-74CEPOFO.js";function x(a,i,d){let g=new Map,h=new Map;for(let[t,e]of Object.entries(d)){let n={name:t,type:e.type};e.short&&g.set(e.short,n),e.long&&h.set(e.long,n)}let s={};for(let[t,e]of Object.entries(d))e.default!==void 0?s[t]=e.default:e.type==="boolean"&&(s[t]=!1);let b=[],k=!1;for(let t=0;t<i.length;t++){let e=i[t];if(k||!e.startsWith("-")||e==="-"){b.push(e);continue}if(e==="--"){k=!0;continue}if(e.startsWith("--")){let n=e.indexOf("="),o,r;n!==-1?(o=e.slice(2,n),r=e.slice(n+1)):o=e.slice(2);let f=h.get(o);if(!f)return{ok:!1,error:p(a,e)};let{name:l,type:u}=f;if(u==="boolean")s[l]=!0;else{if(r===void 0){if(t+1>=i.length)return{ok:!1,error:{stdout:"",stderr:`${a}: option '--${o}' requires an argument
|
|
2
|
+
`,exitCode:1}};r=i[++t]}s[l]=u==="number"?parseInt(r,10):r}}else{let n=e.slice(1);for(let o=0;o<n.length;o++){let r=n[o],f=g.get(r);if(!f)return{ok:!1,error:p(a,`-${r}`)};let{name:l,type:u}=f;if(u==="boolean")s[l]=!0;else{let c;if(o+1<n.length)c=n.slice(o+1);else if(t+1<i.length)c=i[++t];else return{ok:!1,error:{stdout:"",stderr:`${a}: option requires an argument -- '${r}'
|
|
3
|
+
`,exitCode:1}};s[l]=u==="number"?parseInt(c,10):c;break}}}}return{ok:!0,result:{flags:s,positional:b}}}export{x as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,b as r}from"./chunk-74CEPOFO.js";var t={name:"clear",summary:"clear the terminal screen",usage:"clear [OPTIONS]",options:[" --help display this help and exit"]},s={name:"clear",async execute(a,c){return r(a)?e(t):{stdout:"\x1B[2J\x1B[H",stderr:"",exitCode:0}}};export{s as clearCommand};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{a as m}from"./chunk-ZVV5VXYZ.js";import{a as $}from"./chunk-44UOCSGV.js";import{a as g,b as y}from"./chunk-74CEPOFO.js";var D={name:"cp",summary:"copy files and directories",usage:"cp [OPTION]... SOURCE... DEST",options:["-r, -R, --recursive copy directories recursively","-n, --no-clobber do not overwrite an existing file","-p, --preserve preserve file attributes","-v, --verbose explain what is being done"," --help display this help and exit"]},E={recursive:{short:"r",long:"recursive",type:"boolean"},recursiveUpper:{short:"R",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},preserve:{short:"p",long:"preserve",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},R={name:"cp",async execute(f,e){if(y(f))return g(D);let t=m("cp",f,E);if(!t.ok)return t.error;let u=t.result.flags.recursive||t.result.flags.recursiveUpper,w=t.result.flags.noClobber,C=t.result.flags.preserve,P=t.result.flags.verbose,a=t.result.positional;if(a.length<2)return{stdout:"",stderr:`cp: missing destination file operand
|
|
2
|
+
`,exitCode:1};let d=a.pop()??"",h=a,o=e.fs.resolvePath(e.cwd,d),v="",n="",l=0,p=!1;try{p=(await e.fs.stat(o)).isDirectory}catch{}if(h.length>1&&!p)return{stdout:"",stderr:`cp: target '${d}' is not a directory
|
|
3
|
+
`,exitCode:1};for(let r of h)try{let i=e.fs.resolvePath(e.cwd,r),s=await e.fs.stat(i),c=o;if(p){let b=r.split("/").pop()||r;c=o==="/"?`/${b}`:`${o}/${b}`}if(s.isDirectory&&!u){n+=`cp: -r not specified; omitting directory '${r}'
|
|
4
|
+
`,l=1;continue}if(w)try{await e.fs.stat(c);continue}catch{}await e.fs.cp(i,c,{recursive:u}),P&&(v+=`'${r}' -> '${c}'
|
|
5
|
+
`)}catch(i){let s=$(i);s.includes("ENOENT")||s.includes("no such file")?n+=`cp: cannot stat '${r}': No such file or directory
|
|
6
|
+
`:n+=`cp: cannot copy '${r}': ${s}
|
|
7
|
+
`,l=1}return{stdout:v,stderr:n,exitCode:l}}};export{R as cpCommand};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import{a as b}from"./chunk-44UOCSGV.js";import{a as T,b as y,c as f}from"./chunk-74CEPOFO.js";function u(s){let t=s.indexOf("=");if(t>=0){let r=s.slice(0,t),e=s.slice(t+1);return r?`${encodeURIComponent(r)}=${encodeURIComponent(e)}`:encodeURIComponent(e)}return encodeURIComponent(s)}function c(s){let t=s.indexOf("=");if(t<0)return null;let r=s.slice(0,t),e=s.slice(t+1),i,a,o=e.match(/;type=([^;]+)$/);o&&(a=o[1],e=e.slice(0,-o[0].length));let n=e.match(/;filename=([^;]+)/);return n&&(i=n[1],e=e.replace(n[0],"")),(e.startsWith("@")||e.startsWith("<"))&&(i=i??e.slice(1).split("/").pop()),{name:r,value:e,filename:i,contentType:a}}function w(s,t){let r=`----CurlFormBoundary${Date.now().toString(36)}`,e=[];for(let i of s){let a=i.value;if(a.startsWith("@")||a.startsWith("<")){let n=a.slice(1);a=t.get(n)??""}let o=`--${r}\r
|
|
2
|
+
`;i.filename?(o+=`Content-Disposition: form-data; name="${i.name}"; filename="${i.filename}"\r
|
|
3
|
+
`,i.contentType&&(o+=`Content-Type: ${i.contentType}\r
|
|
4
|
+
`)):o+=`Content-Disposition: form-data; name="${i.name}"\r
|
|
5
|
+
`,o+=`\r
|
|
6
|
+
${a}\r
|
|
7
|
+
`,e.push(o)}return e.push(`--${r}--\r
|
|
8
|
+
`),{body:e.join(""),boundary:r}}var O={name:"curl",summary:"transfer a URL",usage:"curl [OPTIONS] URL",options:["-X, --request METHOD HTTP method (GET, POST, PUT, DELETE, etc.)","-H, --header HEADER Add header (can be used multiple times)","-d, --data DATA HTTP POST data"," --data-raw DATA HTTP POST data (no @ interpretation)"," --data-binary DATA HTTP POST binary data"," --data-urlencode DATA URL-encode and POST data","-F, --form NAME=VALUE Multipart form data","-u, --user USER:PASS HTTP authentication","-A, --user-agent STR Set User-Agent header","-e, --referer URL Set Referer header","-b, --cookie DATA Send cookies (name=value or @file)","-c, --cookie-jar FILE Save cookies to file","-T, --upload-file FILE Upload file (PUT)","-o, --output FILE Write output to file","-O, --remote-name Write to file named from URL","-I, --head Show headers only (HEAD request)","-i, --include Include response headers in output","-s, --silent Silent mode (no progress)","-S, --show-error Show errors even when silent","-f, --fail Fail silently on HTTP errors (no output)","-L, --location Follow redirects (default)"," --max-redirs NUM Maximum redirects (default: 20)","-m, --max-time SECS Maximum time for request"," --connect-timeout SECS Connection timeout","-w, --write-out FMT Output format after completion","-v, --verbose Verbose output"," --help Display this help and exit","","Note: Network access must be configured via BashEnv network option."," curl is not available by default for security reasons."]};function S(s){let t={method:"GET",headers:{},dataBinary:!1,formFields:[],useRemoteName:!1,headOnly:!1,includeHeaders:!1,silent:!1,showError:!1,failSilently:!1,followRedirects:!0,verbose:!1};for(let r=0;r<s.length;r++){let e=s[r];if(e==="-X"||e==="--request")t.method=s[++r]??"GET";else if(e.startsWith("-X"))t.method=e.slice(2);else if(e.startsWith("--request="))t.method=e.slice(10);else if(e==="-H"||e==="--header"){let i=s[++r];if(i){let a=i.indexOf(":");if(a>0){let o=i.slice(0,a).trim(),n=i.slice(a+1).trim();t.headers[o]=n}}}else if(e.startsWith("--header=")){let i=e.slice(9),a=i.indexOf(":");if(a>0){let o=i.slice(0,a).trim(),n=i.slice(a+1).trim();t.headers[o]=n}}else if(e==="-d"||e==="--data"||e==="--data-raw")t.data=s[++r]??"",t.method==="GET"&&(t.method="POST");else if(e.startsWith("-d"))t.data=e.slice(2),t.method==="GET"&&(t.method="POST");else if(e.startsWith("--data="))t.data=e.slice(7),t.method==="GET"&&(t.method="POST");else if(e.startsWith("--data-raw="))t.data=e.slice(11),t.method==="GET"&&(t.method="POST");else if(e==="--data-binary")t.data=s[++r]??"",t.dataBinary=!0,t.method==="GET"&&(t.method="POST");else if(e.startsWith("--data-binary="))t.data=e.slice(14),t.dataBinary=!0,t.method==="GET"&&(t.method="POST");else if(e==="--data-urlencode"){let i=s[++r]??"";t.data=(t.data?`${t.data}&`:"")+u(i),t.method==="GET"&&(t.method="POST")}else if(e.startsWith("--data-urlencode=")){let i=e.slice(17);t.data=(t.data?`${t.data}&`:"")+u(i),t.method==="GET"&&(t.method="POST")}else if(e==="-F"||e==="--form"){let i=s[++r]??"",a=c(i);a&&t.formFields.push(a),t.method==="GET"&&(t.method="POST")}else if(e.startsWith("--form=")){let i=e.slice(7),a=c(i);a&&t.formFields.push(a),t.method==="GET"&&(t.method="POST")}else if(e==="-u"||e==="--user")t.user=s[++r];else if(e.startsWith("-u"))t.user=e.slice(2);else if(e.startsWith("--user="))t.user=e.slice(7);else if(e==="-A"||e==="--user-agent")t.headers["User-Agent"]=s[++r]??"";else if(e.startsWith("-A"))t.headers["User-Agent"]=e.slice(2);else if(e.startsWith("--user-agent="))t.headers["User-Agent"]=e.slice(13);else if(e==="-e"||e==="--referer")t.headers.Referer=s[++r]??"";else if(e.startsWith("-e"))t.headers.Referer=e.slice(2);else if(e.startsWith("--referer="))t.headers.Referer=e.slice(10);else if(e==="-b"||e==="--cookie")t.headers.Cookie=s[++r]??"";else if(e.startsWith("-b"))t.headers.Cookie=e.slice(2);else if(e.startsWith("--cookie="))t.headers.Cookie=e.slice(9);else if(e==="-c"||e==="--cookie-jar")t.cookieJar=s[++r];else if(e.startsWith("--cookie-jar="))t.cookieJar=e.slice(13);else if(e==="-T"||e==="--upload-file")t.uploadFile=s[++r],t.method==="GET"&&(t.method="PUT");else if(e.startsWith("--upload-file="))t.uploadFile=e.slice(14),t.method==="GET"&&(t.method="PUT");else if(e==="-m"||e==="--max-time"){let i=parseFloat(s[++r]??"0");!Number.isNaN(i)&&i>0&&(t.timeoutMs=i*1e3)}else if(e.startsWith("--max-time=")){let i=parseFloat(e.slice(11));!Number.isNaN(i)&&i>0&&(t.timeoutMs=i*1e3)}else if(e==="--connect-timeout"){let i=parseFloat(s[++r]??"0");!Number.isNaN(i)&&i>0&&t.timeoutMs===void 0&&(t.timeoutMs=i*1e3)}else if(e.startsWith("--connect-timeout=")){let i=parseFloat(e.slice(18));!Number.isNaN(i)&&i>0&&t.timeoutMs===void 0&&(t.timeoutMs=i*1e3)}else if(e==="-o"||e==="--output")t.outputFile=s[++r];else if(e.startsWith("--output="))t.outputFile=e.slice(9);else if(e==="-O"||e==="--remote-name")t.useRemoteName=!0;else if(e==="-I"||e==="--head")t.headOnly=!0,t.method="HEAD";else if(e==="-i"||e==="--include")t.includeHeaders=!0;else if(e==="-s"||e==="--silent")t.silent=!0;else if(e==="-S"||e==="--show-error")t.showError=!0;else if(e==="-f"||e==="--fail")t.failSilently=!0;else if(e==="-L"||e==="--location")t.followRedirects=!0;else if(e==="--max-redirs")r++;else if(!e.startsWith("--max-redirs="))if(e==="-w"||e==="--write-out")t.writeOut=s[++r];else if(e.startsWith("--write-out="))t.writeOut=e.slice(12);else if(e==="-v"||e==="--verbose")t.verbose=!0;else{if(e.startsWith("--")&&e!=="--")return f("curl",e);if(e.startsWith("-")&&e!=="-")for(let i of e.slice(1))switch(i){case"s":t.silent=!0;break;case"S":t.showError=!0;break;case"f":t.failSilently=!0;break;case"L":t.followRedirects=!0;break;case"I":t.headOnly=!0,t.method="HEAD";break;case"i":t.includeHeaders=!0;break;case"O":t.useRemoteName=!0;break;case"v":t.verbose=!0;break;default:return f("curl",`-${i}`)}else e.startsWith("-")||(t.url=e)}}return t}function h(s){return Object.entries(s).map(([t,r])=>`${t}: ${r}`).join(`\r
|
|
9
|
+
`)}function E(s){try{return new URL(s).pathname.split("/").pop()||"index.html"}catch{return"index.html"}}function m(s,t){let r=s;return r=r.replace(/%\{http_code\}/g,String(t.status)),r=r.replace(/%\{content_type\}/g,t.headers["content-type"]||""),r=r.replace(/%\{url_effective\}/g,t.url),r=r.replace(/%\{size_download\}/g,String(t.bodyLength)),r=r.replace(/\\n/g,`
|
|
10
|
+
`),r}async function F(s,t){if(s.uploadFile){let r=t.fs.resolvePath(t.cwd,s.uploadFile);return{body:await t.fs.readFile(r)}}if(s.formFields.length>0){let r=new Map;for(let a of s.formFields)if(a.value.startsWith("@")||a.value.startsWith("<")){let o=t.fs.resolvePath(t.cwd,a.value.slice(1));try{let n=await t.fs.readFile(o);r.set(a.value.slice(1),n)}catch{r.set(a.value.slice(1),"")}}let{body:e,boundary:i}=w(s.formFields,r);return{body:e,contentType:`multipart/form-data; boundary=${i}`}}return s.data!==void 0?{body:s.data}:{}}function P(s,t){let r={...s.headers};if(s.user){let e=Buffer.from(s.user).toString("base64");r.Authorization=`Basic ${e}`}return t&&!r["Content-Type"]&&(r["Content-Type"]=t),r}async function W(s,t,r){if(!s.cookieJar)return;let e=t["set-cookie"];if(!e)return;let i=r.fs.resolvePath(r.cwd,s.cookieJar);await r.fs.writeFile(i,e)}function $(s,t,r){let e="";if(s.verbose){e+=`> ${s.method} ${r}
|
|
11
|
+
`;for(let[i,a]of Object.entries(s.headers))e+=`> ${i}: ${a}
|
|
12
|
+
`;e+=`>
|
|
13
|
+
`,e+=`< HTTP/1.1 ${t.status} ${t.statusText}
|
|
14
|
+
`;for(let[i,a]of Object.entries(t.headers))e+=`< ${i}: ${a}
|
|
15
|
+
`;e+=`<
|
|
16
|
+
`}return s.includeHeaders&&!s.verbose&&(e+=`HTTP/1.1 ${t.status} ${t.statusText}\r
|
|
17
|
+
`,e+=h(t.headers),e+=`\r
|
|
18
|
+
\r
|
|
19
|
+
`),s.headOnly?s.includeHeaders||s.verbose||(e+=`HTTP/1.1 ${t.status} ${t.statusText}\r
|
|
20
|
+
`,e+=h(t.headers),e+=`\r
|
|
21
|
+
`):e+=t.body,s.writeOut&&(e+=m(s.writeOut,{status:t.status,headers:t.headers,url:t.url,bodyLength:t.body.length})),e}var I={name:"curl",async execute(s,t){if(y(s))return T(O);let r=S(s);if("exitCode"in r)return r;let e=r;if(!e.url)return{stdout:"",stderr:`curl: no URL specified
|
|
22
|
+
`,exitCode:2};if(!t.fetch)return{stdout:"",stderr:`curl: internal error: fetch not available
|
|
23
|
+
`,exitCode:1};let i=e.url;i.match(/^https?:\/\//)||(i=`https://${i}`);try{let{body:a,contentType:o}=await F(e,t),n=P(e,o),l=await t.fetch(i,{method:e.method,headers:Object.keys(n).length>0?n:void 0,body:a,followRedirects:e.followRedirects,timeoutMs:e.timeoutMs});if(await W(e,l.headers,t),e.failSilently&&l.status>=400)return{stdout:"",stderr:e.showError||!e.silent?`curl: (22) The requested URL returned error: ${l.status}
|
|
24
|
+
`:"",exitCode:22};let d=$(e,l,i);if(e.outputFile||e.useRemoteName){let p=e.outputFile||E(i),v=t.fs.resolvePath(t.cwd,p);await t.fs.writeFile(v,e.headOnly?"":l.body),e.verbose||(d=""),e.writeOut&&(d=m(e.writeOut,{status:l.status,headers:l.headers,url:l.url,bodyLength:l.body.length}))}return{stdout:d,stderr:"",exitCode:0}}catch(a){let o=b(a),n=1;return o.includes("Network access denied")?n=7:o.includes("HTTP method")&&o.includes("not allowed")?n=3:o.includes("Redirect target not in allow-list")||o.includes("Too many redirects")?n=47:o.includes("aborted")&&(n=28),{stdout:"",stderr:!e.silent||e.showError?`curl: (${n}) ${o}
|
|
25
|
+
`:"",exitCode:n}}}};export{I as curlCommand};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{b as x}from"./chunk-3YNHMZ5M.js";import{a as y,b as I,c as m}from"./chunk-74CEPOFO.js";var W={name:"cut",summary:"remove sections from each line of files",usage:"cut [OPTION]... [FILE]...",options:["-c LIST select only these characters","-d DELIM use DELIM instead of TAB for field delimiter","-f LIST select only these fields","-s, --only-delimited do not print lines without delimiters"," --help display this help and exit"]};function k(t){let c=[],l=t.split(",");for(let n of l)if(n.includes("-")){let[s,r]=n.split("-");c.push({start:s?parseInt(s,10):1,end:r?parseInt(r,10):null})}else{let s=parseInt(n,10);c.push({start:s,end:s})}return c}function C(t,c){let l=[];for(let n of c){let s=n.start-1,r=n.end===null?t.length:n.end;for(let i=s;i<r&&i<t.length;i++)i>=0&&!l.includes(t[i])&&l.push(t[i])}return l}var E={name:"cut",async execute(t,c){if(I(t))return y(W);let l=" ",n=null,s=null,r=!1,i=[];for(let o=0;o<t.length;o++){let e=t[o];if(e==="-d")l=t[++o]||" ";else if(e.startsWith("-d"))l=e.slice(2);else if(e==="-f")n=t[++o];else if(e.startsWith("-f"))n=e.slice(2);else if(e==="-c")s=t[++o];else if(e.startsWith("-c"))s=e.slice(2);else if(e==="-s"||e==="--only-delimited")r=!0;else{if(e.startsWith("--"))return m("cut",e);if(e.startsWith("-")){let f=!1;for(let u of e.slice(1))if(u==="s")r=!0;else if(!"dfc".includes(u)){f=!0;break}if(f)return m("cut",e)}else i.push(e)}}if(!n&&!s)return{stdout:"",stderr:`cut: you must specify a list of bytes, characters, or fields
|
|
2
|
+
`,exitCode:1};let p=await x(c,i,{cmdName:"cut"});if(!p.ok)return p.error;let a=p.content.split(`
|
|
3
|
+
`);a.length>0&&a[a.length-1]===""&&a.pop();let g=k(n||s||"1"),h="";for(let o of a)if(s){let e=o.split(""),f=[];for(let u of g){let w=u.start-1,L=u.end===null?e.length:u.end;for(let d=w;d<L&&d<e.length;d++)d>=0&&f.push(e[d])}h+=`${f.join("")}
|
|
4
|
+
`}else{if(r&&!o.includes(l))continue;let e=o.split(l),f=C(e,g);h+=`${f.join(l)}
|
|
5
|
+
`}return{stdout:h,stderr:"",exitCode:0}}};export{E as cutCommand};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as g,b as k,c as m}from"./chunk-74CEPOFO.js";var p={name:"date",summary:"display the current time in the given FORMAT",usage:"date [OPTION]... [+FORMAT]",options:["-d, --date=STRING display time described by STRING","-u, --utc print Coordinated Universal Time (UTC)","-I, --iso-8601 output date/time in ISO 8601 format","-R, --rfc-email output RFC 5322 date format"," --help display this help and exit"]},M=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],h=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function n(t,i=2){return String(t).padStart(i,"0")}function T(t){let i=-t.getTimezoneOffset();return`${i>=0?"+":"-"}${n(Math.floor(Math.abs(i)/60))}${n(Math.abs(i)%60)}`}function d(t,i,r){let a=r?{Y:t.getUTCFullYear(),m:t.getUTCMonth(),D:t.getUTCDate(),H:t.getUTCHours(),M:t.getUTCMinutes(),S:t.getUTCSeconds(),w:t.getUTCDay()}:{Y:t.getFullYear(),m:t.getMonth(),D:t.getDate(),H:t.getHours(),M:t.getMinutes(),S:t.getSeconds(),w:t.getDay()},e="",o=0;for(;o<i.length;){if(i[o]==="%"&&o+1<i.length){let c=i[++o];switch(c){case"%":e+="%";break;case"a":e+=M[a.w];break;case"b":case"h":e+=h[a.m];break;case"d":e+=n(a.D);break;case"e":e+=String(a.D).padStart(2," ");break;case"F":e+=`${a.Y}-${n(a.m+1)}-${n(a.D)}`;break;case"H":e+=n(a.H);break;case"I":e+=n(a.H%12||12);break;case"m":e+=n(a.m+1);break;case"M":e+=n(a.M);break;case"n":e+=`
|
|
2
|
+
`;break;case"p":e+=a.H<12?"AM":"PM";break;case"P":e+=a.H<12?"am":"pm";break;case"R":e+=`${n(a.H)}:${n(a.M)}`;break;case"s":e+=Math.floor(t.getTime()/1e3);break;case"S":e+=n(a.S);break;case"t":e+=" ";break;case"T":e+=`${n(a.H)}:${n(a.M)}:${n(a.S)}`;break;case"u":e+=a.w||7;break;case"w":e+=a.w;break;case"y":e+=n(a.Y%100);break;case"Y":e+=a.Y;break;case"z":e+=r?"+0000":T(t);break;case"Z":e+=r?"UTC":Intl.DateTimeFormat().resolvedOptions().timeZone;break;default:e+=`%${c}`}}else e+=i[o];o++}return e}function S(t){let i=new Date(t);if(!Number.isNaN(i.getTime()))return i;if(/^\d+$/.test(t))return new Date(Number.parseInt(t,10)*1e3);let r=t.toLowerCase();return r==="now"||r==="today"?new Date:r==="yesterday"?new Date(Date.now()-864e5):r==="tomorrow"?new Date(Date.now()+864e5):null}var w={name:"date",async execute(t,i){if(k(t))return g(p);let r=!1,a=null,e=null,o=!1,c=!1;for(let f=0;f<t.length;f++){let s=t[f];if(s==="-u"||s==="--utc")r=!0;else if(s==="-d"||s==="--date")a=t[++f]??"";else if(s.startsWith("--date="))a=s.slice(7);else if(s==="-I"||s==="--iso-8601")o=!0;else if(s==="-R"||s==="--rfc-email")c=!0;else if(s.startsWith("+"))e=s.slice(1);else{if(s.startsWith("--"))return m("date",s);if(s.startsWith("-"))for(let b of s.slice(1))if(b==="u")r=!0;else if(b==="I")o=!0;else if(b==="R")c=!0;else return m("date",`-${b}`)}}let l=a!==null?S(a):new Date;if(!l)return{stdout:"",stderr:`date: invalid date '${a}'
|
|
3
|
+
`,exitCode:1};let u;return e?u=d(l,e,r):o?u=d(l,"%Y-%m-%dT%H:%M:%S%z",r):c?u=d(l,"%a, %d %b %Y %H:%M:%S %z",r):u=d(l,"%a %b %e %H:%M:%S %Z %Y",r),{stdout:`${u}
|
|
4
|
+
`,stderr:"",exitCode:0}}};export{w as dateCommand};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as p}from"./chunk-ZVV5VXYZ.js";import{a as l,b as u}from"./chunk-74CEPOFO.js";import*as c from"diff";var y={name:"diff",summary:"compare files line by line",usage:"diff [OPTION]... FILE1 FILE2",options:["-u, --unified output unified diff format (default)","-q, --brief report only whether files differ","-s, --report-identical-files report when files are the same","-i, --ignore-case ignore case differences"," --help display this help and exit"]},C={unified:{short:"u",long:"unified",type:"boolean"},brief:{short:"q",long:"brief",type:"boolean"},reportSame:{short:"s",long:"report-identical-files",type:"boolean"},ignoreCase:{short:"i",long:"ignore-case",type:"boolean"}},$={name:"diff",async execute(d,e){if(u(d))return l(y);let t=p("diff",d,C);if(!t.ok)return t.error;let h=t.result.flags.brief,g=t.result.flags.reportSame,m=t.result.flags.ignoreCase,a=t.result.positional;if(t.result.flags.unified,a.length<2)return{stdout:"",stderr:`diff: missing operand
|
|
2
|
+
`,exitCode:2};let o,s,[r,i]=a;try{o=r==="-"?e.stdin:await e.fs.readFile(e.fs.resolvePath(e.cwd,r))}catch{return{stdout:"",stderr:`diff: ${r}: No such file or directory
|
|
3
|
+
`,exitCode:2}}try{s=i==="-"?e.stdin:await e.fs.readFile(e.fs.resolvePath(e.cwd,i))}catch{return{stdout:"",stderr:`diff: ${i}: No such file or directory
|
|
4
|
+
`,exitCode:2}}let f=o,n=s;return m&&(f=f.toLowerCase(),n=n.toLowerCase()),f===n?g?{stdout:`Files ${r} and ${i} are identical
|
|
5
|
+
`,stderr:"",exitCode:0}:{stdout:"",stderr:"",exitCode:0}:h?{stdout:`Files ${r} and ${i} differ
|
|
6
|
+
`,stderr:"",exitCode:1}:{stdout:c.createTwoFilesPatch(r,i,o,s,"","",{context:3}),stderr:"",exitCode:1}}};export{$ as diffCommand};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as i,b as o}from"./chunk-74CEPOFO.js";var m={name:"dirname",summary:"strip last component from file name",usage:"dirname [OPTION] NAME...",options:[" --help display this help and exit"]},p={name:"dirname",async execute(t,l){if(o(t))return i(m);let a=t.filter(n=>!n.startsWith("-"));if(a.length===0)return{stdout:"",stderr:`dirname: missing operand
|
|
2
|
+
`,exitCode:1};let e=[];for(let n of a){let r=n.replace(/\/+$/,""),s=r.lastIndexOf("/");s===-1?e.push("."):s===0?e.push("/"):e.push(r.slice(0,s))}return{stdout:`${e.join(`
|
|
3
|
+
`)}
|
|
4
|
+
`,stderr:"",exitCode:0}}};export{p as dirnameCommand};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{a as z}from"./chunk-ZVV5VXYZ.js";import{a as p,b as g}from"./chunk-74CEPOFO.js";var $={name:"du",summary:"estimate file space usage",usage:"du [OPTION]... [FILE]...",options:["-a write counts for all files, not just directories","-h print sizes in human readable format","-s display only a total for each argument","-c produce a grand total","--max-depth=N print total for directory only if N or fewer levels deep"," --help display this help and exit"]},D={allFiles:{short:"a",type:"boolean"},humanReadable:{short:"h",type:"boolean"},summarize:{short:"s",type:"boolean"},grandTotal:{short:"c",type:"boolean"},maxDepth:{long:"max-depth",type:"number"}},F={name:"du",async execute(t,l){if(g(t))return p($);let a=z("du",t,D);if(!a.ok)return a.error;let e={allFiles:a.result.flags.allFiles,humanReadable:a.result.flags.humanReadable,summarize:a.result.flags.summarize,grandTotal:a.result.flags.grandTotal,maxDepth:a.result.flags.maxDepth??null},s=a.result.positional;s.length===0&&s.push(".");let r="",n="",m=0;for(let o of s){let i=l.fs.resolvePath(l.cwd,o);try{await l.fs.stat(i);let u=await y(l,i,o,e,0);r+=u.output,m+=u.totalSize,n+=u.stderr}catch{n+=`du: cannot access '${o}': No such file or directory
|
|
2
|
+
`}}return e.grandTotal&&s.length>0&&(r+=`${d(m,e.humanReadable)} total
|
|
3
|
+
`),{stdout:r,stderr:n,exitCode:n?1:0}}};async function y(t,l,a,e,s){let r={output:"",totalSize:0,stderr:""};try{let n=await t.fs.stat(l);if(!n.isDirectory)return r.totalSize=n.size,(e.allFiles||s===0)&&(r.output=d(n.size,e.humanReadable)+" "+a+`
|
|
4
|
+
`),r;let m=await t.fs.readdir(l),o=0;for(let i of m){let u=l==="/"?`/${i}`:`${l}/${i}`,f=a==="."?i:`${a}/${i}`;try{let c=await t.fs.stat(u);if(c.isDirectory){let h=await y(t,u,f,e,s+1);o+=h.totalSize,e.summarize||(e.maxDepth===null||s+1<=e.maxDepth?r.output+=h.output:o+=0)}else o+=c.size,e.allFiles&&!e.summarize&&(r.output+=d(c.size,e.humanReadable)+" "+f+`
|
|
5
|
+
`)}catch{}}r.totalSize=o,(e.summarize||e.maxDepth===null||s<=e.maxDepth)&&(r.output+=`${d(o,e.humanReadable)} ${a}
|
|
6
|
+
`)}catch{r.stderr=`du: cannot read directory '${a}': Permission denied
|
|
7
|
+
`}return r}function d(t,l){return l?t<1024?`${t}`:t<1024*1024?`${(t/1024).toFixed(1)}K`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)}M`:`${(t/(1024*1024*1024)).toFixed(1)}G`:String(Math.ceil(t/1024)||1)}export{F as duCommand};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function o(a){let s="",e=0;for(;e<a.length;)if(a[e]==="\\"){if(e+1>=a.length){s+="\\";break}let c=a[e+1];switch(c){case"\\":s+="\\",e+=2;break;case"n":s+=`
|
|
2
|
+
`,e+=2;break;case"t":s+=" ",e+=2;break;case"r":s+="\r",e+=2;break;case"a":s+="\x07",e+=2;break;case"b":s+="\b",e+=2;break;case"f":s+="\f",e+=2;break;case"v":s+="\v",e+=2;break;case"e":case"E":s+="\x1B",e+=2;break;case"c":return{output:s,stop:!0};case"0":{let r="",t=e+2;for(;t<a.length&&t<e+5&&/[0-7]/.test(a[t]);)r+=a[t],t++;if(r.length===0)s+="\0";else{let l=parseInt(r,8)%256;s+=String.fromCharCode(l)}e=t;break}case"x":{let r="",t=e+2;for(;t<a.length&&t<e+4&&/[0-9a-fA-F]/.test(a[t]);)r+=a[t],t++;if(r.length===0)s+="\\x",e+=2;else{let l=parseInt(r,16);s+=String.fromCharCode(l),e=t}break}case"u":{let r="",t=e+2;for(;t<a.length&&t<e+6&&/[0-9a-fA-F]/.test(a[t]);)r+=a[t],t++;if(r.length===0)s+="\\u",e+=2;else{let l=parseInt(r,16);s+=String.fromCodePoint(l),e=t}break}case"U":{let r="",t=e+2;for(;t<a.length&&t<e+10&&/[0-9a-fA-F]/.test(a[t]);)r+=a[t],t++;if(r.length===0)s+="\\U",e+=2;else{let l=parseInt(r,16);try{s+=String.fromCodePoint(l)}catch{s+=`\\U${r}`}e=t}break}default:s+=`\\${c}`,e+=2}}else s+=a[e],e++;return{output:s,stop:!1}}var n={name:"echo",async execute(a,s){let e=!1,c=!1,r=0;for(;r<a.length;){let l=a[r];if(l==="-n")e=!0,r++;else if(l==="-e")c=!0,r++;else if(l==="-E")c=!1,r++;else if(l==="-ne"||l==="-en")e=!0,c=!0,r++;else break}let t=a.slice(r).join(" ");if(c){let l=o(t);if(t=l.output,l.stop)return{stdout:t,stderr:"",exitCode:0}}return e||(t+=`
|
|
3
|
+
`),{stdout:t,stderr:"",exitCode:0}}};export{n as echoCommand};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{a as m,b as f,c as p}from"./chunk-74CEPOFO.js";var O={name:"env",summary:"run a program in a modified environment",usage:"env [OPTION]... [NAME=VALUE]... [COMMAND [ARG]...]",options:["-i, --ignore-environment start with an empty environment","-u NAME, --unset=NAME remove NAME from the environment"," --help display this help and exit"]},y={name:"env",async execute(s,r){if(f(s))return m(O);let u=!1,i=[],l={},t=-1;for(let n=0;n<s.length;n++){let e=s[n];if(e==="-i"||e==="--ignore-environment")u=!0;else if(e==="-u"&&n+1<s.length)i.push(s[++n]);else if(e.startsWith("-u"))i.push(e.slice(2));else if(e.startsWith("--unset="))i.push(e.slice(8));else{if(e.startsWith("--")&&e!=="--")return p("env",e);if(e.startsWith("-")&&e!=="-"){for(let o of e.slice(1))if(o!=="i"&&o!=="u")return p("env",`-${o}`);e.includes("i")&&(u=!0)}else if(e.includes("=")&&t===-1){let o=e.indexOf("="),h=e.slice(0,o),x=e.slice(o+1);l[h]=x}else{t=n;break}}}let a;if(u)a={...l};else{a={...r.env};for(let n of i)delete a[n];Object.assign(a,l)}if(t===-1){let n=[];for(let[e,o]of Object.entries(a))n.push(`${e}=${o}`);return{stdout:n.join(`
|
|
2
|
+
`)+(n.length>0?`
|
|
3
|
+
`:""),stderr:"",exitCode:0}}if(!r.exec)return{stdout:"",stderr:`env: command execution not supported in this context
|
|
4
|
+
`,exitCode:1};let c=s.slice(t).join(" "),v=Object.entries(l).map(([n,e])=>`${n}="${e}"`).join(" "),d=v?`${v} ${c}`:c;return r.exec(d)}},g={name:"printenv",summary:"print all or part of environment",usage:"printenv [OPTION]... [VARIABLE]...",options:[" --help display this help and exit"]},A={name:"printenv",async execute(s,r){if(f(s))return m(g);let u=s.filter(t=>!t.startsWith("-"));if(u.length===0){let t=[];for(let[a,c]of Object.entries(r.env))t.push(`${a}=${c}`);return{stdout:t.join(`
|
|
5
|
+
`)+(t.length>0?`
|
|
6
|
+
`:""),stderr:"",exitCode:0}}let i=[],l=0;for(let t of u)t in r.env?i.push(r.env[t]):l=1;return{stdout:i.join(`
|
|
7
|
+
`)+(i.length>0?`
|
|
8
|
+
`:""),stderr:"",exitCode:l}}};export{y as envCommand,A as printenvCommand};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var d={name:"expr",async execute(s,r){if(s.length===0)return{stdout:"",stderr:`expr: missing operand
|
|
2
|
+
`,exitCode:2};try{let l=g(s),h=l==="0"||l===""?1:0;return{stdout:`${l}
|
|
3
|
+
`,stderr:"",exitCode:h}}catch(l){return{stdout:"",stderr:`expr: ${l.message}
|
|
4
|
+
`,exitCode:2}}}};function g(s){if(s.length===1)return s[0];let r=0;function l(){let e=h();for(;r<s.length&&s[r]==="|";){r++;let t=h();if(e!=="0"&&e!=="")return e;e=t}return e}function h(){let e=a();for(;r<s.length&&s[r]==="&";){r++;let t=a();(e==="0"||e===""||t==="0"||t==="")&&(e="0")}return e}function a(){let e=p();for(;r<s.length;){let t=s[r];if(["=","!=","<",">","<=",">="].includes(t)){r++;let o=p(),n=parseInt(e,10),i=parseInt(o,10),f=!Number.isNaN(n)&&!Number.isNaN(i),c;t==="="?c=f?n===i:e===o:t==="!="?c=f?n!==i:e!==o:t==="<"?c=f?n<i:e<o:t===">"?c=f?n>i:e>o:t==="<="?c=f?n<=i:e<=o:c=f?n>=i:e>=o,e=c?"1":"0"}else break}return e}function p(){let e=N();for(;r<s.length;){let t=s[r];if(t==="+"||t==="-"){r++;let o=N(),n=parseInt(e,10),i=parseInt(o,10);if(Number.isNaN(n)||Number.isNaN(i))throw new Error("non-integer argument");e=String(t==="+"?n+i:n-i)}else break}return e}function N(){let e=m();for(;r<s.length;){let t=s[r];if(t==="*"||t==="/"||t==="%"){r++;let o=m(),n=parseInt(e,10),i=parseInt(o,10);if(Number.isNaN(n)||Number.isNaN(i))throw new Error("non-integer argument");if((t==="/"||t==="%")&&i===0)throw new Error("division by zero");t==="*"?e=String(n*i):t==="/"?e=String(Math.trunc(n/i)):e=String(n%i)}else break}return e}function m(){let e=u();for(;r<s.length&&s[r]===":";){r++;let t=u(),o=new RegExp(`^${t}`),n=e.match(o);n?e=n[1]!==void 0?n[1]:String(n[0].length):e="0"}return e}function u(){if(r>=s.length)throw new Error("syntax error");let e=s[r];if(e==="match"){r++;let t=u(),o=u(),n=new RegExp(o),i=t.match(n);return i?i[1]!==void 0?i[1]:String(i[0].length):"0"}if(e==="substr"){r++;let t=u(),o=parseInt(u(),10),n=parseInt(u(),10);if(Number.isNaN(o)||Number.isNaN(n))throw new Error("non-integer argument");return t.substring(o-1,o-1+n)}if(e==="index"){r++;let t=u(),o=u();for(let n=0;n<t.length;n++)if(o.includes(t[n]))return String(n+1);return"0"}if(e==="length"){r++;let t=u();return String(t.length)}if(e==="("){r++;let t=l();if(r>=s.length||s[r]!==")")throw new Error("syntax error");return r++,t}return r++,e}return l()}export{d as exprCommand};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import{a as v}from"./chunk-UJMN5NLH.js";import{a as N,b as C}from"./chunk-74CEPOFO.js";function b(e,o){switch(e.type){case"name":return v(o.name,e.pattern,e.ignoreCase);case"path":return v(o.relativePath,e.pattern,e.ignoreCase);case"type":return e.fileType==="f"?o.isFile:e.fileType==="d"?o.isDirectory:!1;case"empty":return o.isEmpty;case"mtime":{let r=(Date.now()-o.mtime)/(1e3*60*60*24);return e.comparison==="more"?r>e.days:e.comparison==="less"?r<e.days:Math.floor(r)===e.days}case"newer":{let s=o.newerRefTimes.get(e.refPath);return s===void 0?!1:o.mtime>s}case"size":{let s=e.value;switch(e.unit){case"c":s=e.value;break;case"k":s=e.value*1024;break;case"M":s=e.value*1024*1024;break;case"G":s=e.value*1024*1024*1024;break;case"b":s=e.value*512;break}return e.comparison==="more"?o.size>s:e.comparison==="less"?o.size<s:e.unit==="b"?Math.ceil(o.size/512)===e.value:o.size===s}case"perm":{let s=o.mode&511,r=e.mode&511;return e.matchType==="exact"?s===r:e.matchType==="all"?(s&r)===r:(s&r)!==0}case"not":return!b(e.expr,o);case"and":return b(e.left,o)&&b(e.right,o);case"or":return b(e.left,o)||b(e.right,o)}}function P(e){let o=[],s=r=>{r&&(r.type==="newer"?o.push(r.refPath):r.type==="not"?s(r.expr):(r.type==="and"||r.type==="or")&&(s(r.left),s(r.right)))};return s(e),o}function R(e,o){let s=[],r=[],i=o;for(;i<e.length;){let t=e[i];if(t==="-name"&&i+1<e.length)s.push({type:"expr",expr:{type:"name",pattern:e[++i]}});else if(t==="-iname"&&i+1<e.length)s.push({type:"expr",expr:{type:"name",pattern:e[++i],ignoreCase:!0}});else if(t==="-path"&&i+1<e.length)s.push({type:"expr",expr:{type:"path",pattern:e[++i]}});else if(t==="-ipath"&&i+1<e.length)s.push({type:"expr",expr:{type:"path",pattern:e[++i],ignoreCase:!0}});else if(t==="-type"&&i+1<e.length){let n=e[++i];if(n==="f"||n==="d")s.push({type:"expr",expr:{type:"type",fileType:n}});else return{expr:null,pathIndex:i,error:`find: Unknown argument to -type: ${n}
|
|
2
|
+
`,actions:[]}}else if(t==="-empty")s.push({type:"expr",expr:{type:"empty"}});else if(t==="-mtime"&&i+1<e.length){let n=e[++i],p="exact",h=n;n.startsWith("+")?(p="more",h=n.slice(1)):n.startsWith("-")&&(p="less",h=n.slice(1));let u=parseInt(h,10);Number.isNaN(u)||s.push({type:"expr",expr:{type:"mtime",days:u,comparison:p}})}else if(t==="-newer"&&i+1<e.length){let n=e[++i];s.push({type:"expr",expr:{type:"newer",refPath:n}})}else if(t==="-size"&&i+1<e.length){let n=e[++i],p="exact",h=n;n.startsWith("+")?(p="more",h=n.slice(1)):n.startsWith("-")&&(p="less",h=n.slice(1));let u=h.match(/^(\d+)([ckMGb])?$/);if(u){let w=parseInt(u[1],10),x=u[2]||"b";s.push({type:"expr",expr:{type:"size",value:w,unit:x,comparison:p}})}}else if(t==="-perm"&&i+1<e.length){let n=e[++i],p="exact",h=n;n.startsWith("-")?(p="all",h=n.slice(1)):n.startsWith("/")&&(p="any",h=n.slice(1));let u=parseInt(h,8);Number.isNaN(u)||s.push({type:"expr",expr:{type:"perm",mode:u,matchType:p}})}else if(t==="-not"||t==="!")s.push({type:"not"});else if(t==="-o"||t==="-or")s.push({type:"op",op:"or"});else if(t==="-a"||t==="-and")s.push({type:"op",op:"and"});else if(t==="-maxdepth"||t==="-mindepth")i++;else if(t==="-exec"){let n=[];for(i++;i<e.length&&e[i]!==";"&&e[i]!=="+";)n.push(e[i]),i++;if(i>=e.length)return{expr:null,pathIndex:i,error:"find: missing argument to `-exec'\n",actions:[]};let p=e[i]==="+";r.push({type:"exec",command:n,batchMode:p})}else if(t==="-print")r.push({type:"print"});else if(t==="-print0")r.push({type:"print0"});else if(t==="-delete")r.push({type:"delete"});else{if(t.startsWith("-"))return{expr:null,pathIndex:i,error:`find: unknown predicate '${t}'
|
|
3
|
+
`,actions:[]};if(s.length===0){i++;continue}break}i++}if(s.length===0)return{expr:null,pathIndex:i,actions:r};let g=[];for(let t=0;t<s.length;t++){let n=s[t];if(n.type==="not"){if(t+1<s.length&&s[t+1].type==="expr"){let p=s[t+1].expr;g.push({type:"expr",expr:{type:"not",expr:p}}),t++}}else(n.type==="expr"||n.type==="op")&&g.push(n)}let E=[[]];for(let t of g)t.type==="op"&&t.op==="or"?E.push([]):t.type==="expr"&&E[E.length-1].push(t.expr);let y=[];for(let t of E){if(t.length===0)continue;let n=t[0];for(let p=1;p<t.length;p++)n={type:"and",left:n,right:t[p]};y.push(n)}if(y.length===0)return{expr:null,pathIndex:i,actions:r};let T=y[0];for(let t=1;t<y.length;t++)T={type:"or",left:T,right:y[t]};return{expr:T,pathIndex:i,actions:r}}var $={name:"find",summary:"search for files in a directory hierarchy",usage:"find [path...] [expression]",options:["-name PATTERN file name matches shell pattern PATTERN","-iname PATTERN like -name but case insensitive","-path PATTERN file path matches shell pattern PATTERN","-ipath PATTERN like -path but case insensitive","-type TYPE file is of type: f (regular file), d (directory)","-empty file is empty or directory is empty","-mtime N file's data was modified N*24 hours ago","-newer FILE file was modified more recently than FILE","-size N[ckMGb] file uses N units of space (c=bytes, k=KB, M=MB, G=GB, b=512B blocks)","-perm MODE file's permission bits are exactly MODE (octal)","-perm -MODE all permission bits MODE are set","-perm /MODE any permission bits MODE are set","-maxdepth LEVELS descend at most LEVELS directories","-mindepth LEVELS do not apply tests at levels less than LEVELS","-not, ! negate the following expression","-a, -and logical AND (default)","-o, -or logical OR","-exec CMD {} ; execute CMD on each file ({} is replaced by filename)","-exec CMD {} + execute CMD with multiple files at once","-print print the full file name (default action)","-print0 print the full file name followed by a null character","-delete delete found files/directories"," --help display this help and exit"]},A=new Set(["-name","-iname","-path","-ipath","-type","-maxdepth","-mindepth","-mtime","-newer","-size","-perm"]),G={name:"find",async execute(e,o){if(C(e))return N($);let s=".",r=null,i=null;for(let l=0;l<e.length;l++){let a=e[l];if(a==="-maxdepth"&&l+1<e.length)r=parseInt(e[++l],10);else if(a==="-mindepth"&&l+1<e.length)i=parseInt(e[++l],10);else if(a==="-exec")for(l++;l<e.length&&e[l]!==";"&&e[l]!=="+";)l++;else!a.startsWith("-")&&a!==";"&&a!=="+"?s=a:A.has(a)&&l++}let{expr:g,error:E,actions:y}=R(e,0);if(E)return{stdout:"",stderr:E,exitCode:1};let T=y.length===0,t=o.fs.resolvePath(o.cwd,s);try{await o.fs.stat(t)}catch{return{stdout:"",stderr:`find: ${s}: No such file or directory
|
|
4
|
+
`,exitCode:1}}let n=[],p=P(g),h=new Map;for(let l of p){let a=o.fs.resolvePath(o.cwd,l);try{let f=await o.fs.stat(a);h.set(l,f.mtime?.getTime()??Date.now())}catch{}}async function u(l,a){if(r!==null&&a>r)return;let f;try{f=await o.fs.stat(l)}catch{return}if(!f)return;let m;l===t?m=s.split("/").pop()||s:m=l.split("/").pop()||"";let c=l===t?s:s==="."?`./${l.slice(t.length+1)}`:s+l.slice(t.length),d=null;f.isDirectory&&(d=await o.fs.readdir(l));let z=f.isFile?f.size===0:d!==null&&d.length===0,D=i===null||a>=i;if(D&&g!==null){let k={name:m,relativePath:c,isFile:f.isFile,isDirectory:f.isDirectory,isEmpty:z,mtime:f.mtime?.getTime()??Date.now(),size:f.size??0,mode:f.mode??420,newerRefTimes:h};D=b(g,k)}if(D&&n.push(c),d!==null)for(let k of d){let I=l==="/"?`/${k}`:`${l}/${k}`;await u(I,a+1)}}await u(t,0);let w="",x="",M=0;if(y.length>0)for(let l of y)switch(l.type){case"print":w+=n.length>0?`${n.join(`
|
|
5
|
+
`)}
|
|
6
|
+
`:"";break;case"print0":w+=n.length>0?`${n.join("\0")}\0`:"";break;case"delete":{let a=[...n].sort((f,m)=>m.length-f.length);for(let f of a){let m=o.fs.resolvePath(o.cwd,f);try{await o.fs.rm(m,{recursive:!1})}catch(c){let d=c instanceof Error?c.message:String(c);x+=`find: cannot delete '${f}': ${d}
|
|
7
|
+
`,M=1}}break}case"exec":if(!o.exec)return{stdout:"",stderr:`find: -exec not supported in this context
|
|
8
|
+
`,exitCode:1};if(l.batchMode){let a=[];for(let c of l.command)c==="{}"?a.push(...n):a.push(c);let f=a.map(c=>`"${c}"`).join(" "),m=await o.exec(f);w+=m.stdout,x+=m.stderr,m.exitCode!==0&&(M=m.exitCode)}else for(let a of n){let m=l.command.map(d=>d==="{}"?a:d).map(d=>`"${d}"`).join(" "),c=await o.exec(m);w+=c.stdout,x+=c.stderr,c.exitCode!==0&&(M=c.exitCode)}break}else T&&(w=n.length>0?`${n.join(`
|
|
9
|
+
`)}
|
|
10
|
+
`:"");return{stdout:w,stderr:x,exitCode:M}}};export{G as findCommand};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{a as N}from"./chunk-UJMN5NLH.js";import{a as q,b as G,c as O}from"./chunk-74CEPOFO.js";var j={name:"grep",summary:"print lines that match patterns",usage:"grep [OPTION]... PATTERN [FILE]...",options:["-E, --extended-regexp PATTERN is an extended regular expression","-F, --fixed-strings PATTERN is a set of newline-separated strings","-i, --ignore-case ignore case distinctions","-v, --invert-match select non-matching lines","-w, --word-regexp match only whole words","-c, --count print only a count of matching lines","-l, --files-with-matches print only names of files with matches","-L, --files-without-match print names of files with no matches","-n, --line-number print line number with output lines","-h, --no-filename suppress the file name prefix on output","-o, --only-matching show only nonempty parts of lines that match","-q, --quiet, --silent suppress all normal output","-r, -R, --recursive search directories recursively","-A NUM print NUM lines of trailing context","-B NUM print NUM lines of leading context","-C NUM print NUM lines of context","-e PATTERN use PATTERN for matching"," --include=GLOB search only files matching GLOB"," --exclude=GLOB skip files matching GLOB"," --exclude-dir=DIR skip directories matching DIR"," --help display this help and exit"]},k={name:"grep",async execute(s,e){if(G(s))return q(j);let o=!1,r=!1,f=!1,u=!1,w=!1,p=!1,h=!1,d=!1,g=!1,m=!1,y=!1,L=!1,x=!1,v=0,l=0,C=[],i=[],n=[],I=null,P=[];for(let a=0;a<s.length;a++){let c=s[a];if(c.startsWith("-")&&c!=="-"){if(c==="-e"&&a+1<s.length){I=s[++a];continue}if(c.startsWith("--include=")){C.push(c.slice(10));continue}if(c.startsWith("--exclude=")){i.push(c.slice(10));continue}if(c.startsWith("--exclude-dir=")){n.push(c.slice(14));continue}let $=c.match(/^-([ABC])(\d+)$/);if($){let t=parseInt($[2],10);$[1]==="A"?l=t:$[1]==="B"?v=t:$[1]==="C"&&(v=t,l=t);continue}if((c==="-A"||c==="-B"||c==="-C")&&a+1<s.length){let t=parseInt(s[++a],10);c==="-A"?l=t:c==="-B"?v=t:(v=t,l=t);continue}let A=c.startsWith("--")?[c]:c.slice(1).split("");for(let t of A)if(t==="i"||t==="--ignore-case")o=!0;else if(t==="n"||t==="--line-number")r=!0;else if(t==="v"||t==="--invert-match")f=!0;else if(t==="c"||t==="--count")u=!0;else if(t==="l"||t==="--files-with-matches")w=!0;else if(t==="L"||t==="--files-without-match")p=!0;else if(t==="r"||t==="R"||t==="--recursive")h=!0;else if(t==="w"||t==="--word-regexp")d=!0;else if(t==="E"||t==="--extended-regexp")g=!0;else if(t==="F"||t==="--fixed-strings")m=!0;else if(t==="o"||t==="--only-matching")y=!0;else if(t==="h"||t==="--no-filename")L=!0;else if(t==="q"||t==="--quiet"||t==="--silent")x=!0;else{if(t.startsWith("--"))return O("grep",t);if(t.length===1)return O("grep",`-${t}`)}}else I===null?I=c:P.push(c)}if(I===null)return{stdout:"",stderr:`grep: missing pattern
|
|
2
|
+
`,exitCode:2};let R;m?R=I.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"):g?R=I:R=z(I),d&&(R=`\\b${R}\\b`);let B;try{B=new RegExp(R,o?"gi":"g")}catch{return{stdout:"",stderr:`grep: invalid regular expression: ${I}
|
|
3
|
+
`,exitCode:2}}if(P.length===0&&e.stdin){let a=b(e.stdin,B,f,r,u,"",y,v,l);return x?{stdout:"",stderr:"",exitCode:a.matched?0:1}:{stdout:a.output,stderr:"",exitCode:a.matched?0:1}}if(P.length===0)return{stdout:"",stderr:`grep: no input files
|
|
4
|
+
`,exitCode:2};let E="",W="",Q=!1,U=!1,M=[];for(let a of P)if(a.includes("*")||a.includes("?")||a.includes("[")){let c=await J(a,e);if(h)for(let $ of c){let A=await S($,e,C,i,n);M.push(...A)}else M.push(...c)}else if(h){let c=await S(a,e,C,i,n);M.push(...c)}else M.push(a);let H=(M.length>1||h)&&!L;for(let a of M){let c=a.split("/").pop()||a;if(!(i.length>0&&!h&&i.some($=>N(c,$,{stripQuotes:!0})))&&!(C.length>0&&!h&&!C.some($=>N(c,$,{stripQuotes:!0}))))try{let $=e.fs.resolvePath(e.cwd,a);if((await e.fs.stat($)).isDirectory){h||(W+=`grep: ${a}: Is a directory
|
|
5
|
+
`);continue}let t=await e.fs.readFile($),F=b(t,B,f,r,u,H?a:"",y,v,l);if(F.matched){if(Q=!0,x)return{stdout:"",stderr:"",exitCode:0};w?E+=`${a}
|
|
6
|
+
`:p||(E+=F.output)}else p?E+=`${a}
|
|
7
|
+
`:u&&!w&&(E+=F.output)}catch{W+=`grep: ${a}: No such file or directory
|
|
8
|
+
`,U=!0}}let T;return U?T=2:p?T=E.length>0?0:1:T=Q?0:1,x?{stdout:"",stderr:"",exitCode:T}:{stdout:E,stderr:W,exitCode:T}}};function z(s){let e="",o=0;for(;o<s.length;){let r=s[o];if(r==="\\"&&o+1<s.length){let f=s[o+1];if(f==="|"||f==="("||f===")"){e+=f,o+=2;continue}else if(f==="{"||f==="}"){e+=`\\${f}`,o+=2;continue}}r==="+"||r==="?"||r==="|"||r==="("||r===")"||r==="{"||r==="}"?e+=`\\${r}`:e+=r,o++}return e}function b(s,e,o,r,f,u,w=!1,p=0,h=0){let d=s.split(`
|
|
9
|
+
`),g=d.length,m=g>0&&d[g-1]===""?g-1:g;if(f){let l=0;for(let i=0;i<m;i++)e.lastIndex=0,e.test(d[i])!==o&&l++;return{output:`${u?`${u}:${l}`:String(l)}
|
|
10
|
+
`,matched:l>0}}if(p===0&&h===0){let l=[],C=!1;for(let i=0;i<m;i++){let n=d[i];if(e.lastIndex=0,e.test(n)!==o)if(C=!0,w){e.lastIndex=0;for(let P=e.exec(n);P!==null;P=e.exec(n))l.push(u?`${u}:${P[0]}`:P[0]),P[0].length===0&&e.lastIndex++}else r?l.push(u?`${u}:${i+1}:${n}`:`${i+1}:${n}`):l.push(u?`${u}:${n}`:n)}return{output:l.length>0?`${l.join(`
|
|
11
|
+
`)}
|
|
12
|
+
`:"",matched:C}}let y=[],L=0,x=new Set,v=[];for(let l=0;l<m;l++)e.lastIndex=0,e.test(d[l])!==o&&(v.push(l),L++);for(let l of v){for(let i=Math.max(0,l-p);i<l;i++)if(!x.has(i)){x.add(i);let n=d[i];r&&(n=`${i+1}-${n}`),u&&(n=`${u}-${n}`),y.push(n)}if(!x.has(l)){x.add(l);let i=d[l];if(w){e.lastIndex=0;for(let n=e.exec(i);n!==null;n=e.exec(i))y.push(u?`${u}:${n[0]}`:n[0]),n[0].length===0&&e.lastIndex++}else{let n=i;r&&(n=`${l+1}:${n}`),u&&(n=`${u}:${n}`),y.push(n)}}let C=Math.min(m-1,l+h);for(let i=l+1;i<=C;i++)if(!x.has(i)){x.add(i);let n=d[i];r&&(n=`${i+1}-${n}`),u&&(n=`${u}-${n}`),y.push(n)}}return{output:y.length>0?`${y.join(`
|
|
13
|
+
`)}
|
|
14
|
+
`:"",matched:L>0}}async function S(s,e,o=[],r=[],f=[]){let u=e.fs.resolvePath(e.cwd,s),w=[];try{if(!(await e.fs.stat(u)).isDirectory){let g=s.split("/").pop()||s;return r.length>0&&r.some(m=>N(g,m,{stripQuotes:!0}))?[]:o.length>0&&!o.some(m=>N(g,m,{stripQuotes:!0}))?[]:[s]}let h=s.split("/").pop()||s;if(f.length>0&&f.some(g=>N(h,g,{stripQuotes:!0})))return[];let d=await e.fs.readdir(u);for(let g of d){if(g.startsWith("."))continue;let m=s==="."?g:`${s}/${g}`,y=await S(m,e,o,r,f);w.push(...y)}}catch{}return w}async function J(s,e){let o=[],r=s.lastIndexOf("/"),f,u;if(r===-1?(f=e.cwd,u=s):(f=s.slice(0,r)||"/",u=s.slice(r+1)),s.includes("**")){let p=s.split("**"),h=p[0].replace(/\/$/,"")||".",d=p[1]||"";return await D(h,d,e,o),o}let w=e.fs.resolvePath(e.cwd,f);try{let p=await e.fs.readdir(w);for(let h of p)if(N(h,u,{stripQuotes:!0})){let d=r===-1?h:`${f}/${h}`;o.push(d)}}catch{}return o.sort()}async function D(s,e,o,r){let f=o.fs.resolvePath(o.cwd,s);try{if(!(await o.fs.stat(f)).isDirectory){let p=s.split("/").pop()||"";if(e){let h=e.replace(/^\//,"");N(p,h,{stripQuotes:!0})&&r.push(s)}return}let w=await o.fs.readdir(f);for(let p of w){let h=s==="."?p:`${s}/${p}`,d=o.fs.resolvePath(o.cwd,h);if((await o.fs.stat(d)).isDirectory)await D(h,e,o,r);else if(e){let m=e.replace(/^\//,"");N(p,m,{stripQuotes:!0})&&r.push(h)}}}catch{}}var X={name:"fgrep",async execute(s,e){return k.execute(["-F",...s],e)}},Y={name:"egrep",async execute(s,e){return k.execute(["-E",...s],e)}};export{Y as egrepCommand,X as fgrepCommand,k as grepCommand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as i,b as r,c as n}from"./chunk-W2EKKAIL.js";import{a as t,b as a}from"./chunk-74CEPOFO.js";var h={name:"head",summary:"output the first part of files",usage:"head [OPTION]... [FILE]...",options:["-c, --bytes=NUM print the first NUM bytes","-n, --lines=NUM print the first NUM lines (default 10)","-q, --quiet never print headers giving file names","-v, --verbose always print headers giving file names"," --help display this help and exit"]},u={name:"head",async execute(s,o){if(a(s))return t(h);let e=i(s,"head");if(!e.ok)return e.error;let{lines:p,bytes:l}=e.options;return r(o,e.options,"head",d=>n(d,p,l))}};export{u as headCommand};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var c={"File operations":["ls","cat","head","tail","wc","touch","mkdir","rm","cp","mv","ln","chmod","stat","readlink"],"Text processing":["grep","sed","awk","sort","uniq","cut","tr","tee","diff"],Search:["find"],"Navigation & paths":["pwd","basename","dirname","tree","du"],"Environment & shell":["echo","printf","env","printenv","export","alias","unalias","history","clear","true","false","bash","sh"],"Data processing":["xargs","jq","base64","date"],Network:["curl","html-to-markdown"]};function l(t){let e=[],n=new Set(t);e.push(`Available commands:
|
|
2
|
+
`);let s=[];for(let[o,r]of Object.entries(c)){let a=r.filter(i=>n.has(i));if(a.length>0){e.push(` ${o}:`),e.push(` ${a.join(", ")}
|
|
3
|
+
`);for(let i of a)n.delete(i)}}for(let o of n)s.push(o);return s.length>0&&(e.push(" Other:"),e.push(` ${s.sort().join(", ")}
|
|
4
|
+
`)),e.push("Use '<command> --help' for details on a specific command."),`${e.join(`
|
|
5
|
+
`)}
|
|
6
|
+
`}var d={name:"help",async execute(t,e){if(t.includes("--help")||t.includes("-h"))return{stdout:`help - display available commands
|
|
7
|
+
|
|
8
|
+
Usage: help [command]
|
|
9
|
+
|
|
10
|
+
Options:
|
|
11
|
+
-h, --help Show this help message
|
|
12
|
+
|
|
13
|
+
If a command name is provided, shows help for that command.
|
|
14
|
+
Otherwise, lists all available commands.
|
|
15
|
+
`,stderr:"",exitCode:0};if(t.length>0&&e.exec){let s=t[0];return e.exec(`${s} --help`)}let n=e.getRegisteredCommands?.()??[];return{stdout:l(n),stderr:"",exitCode:0}}};export{d as helpCommand};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as i,b as h}from"./chunk-74CEPOFO.js";var d={name:"history",summary:"display command history",usage:"history [n]",options:["-c clear the history list"," --help display this help and exit"]},l="BASH_HISTORY",m={name:"history",async execute(e,n){if(h(e))return i(d);let a=n.env[l]||"[]",t;try{t=JSON.parse(a)}catch{t=[]}if(e[0]==="-c")return n.env[l]="[]",{stdout:"",stderr:"",exitCode:0};let s=t.length;e[0]&&/^\d+$/.test(e[0])&&(s=Math.min(parseInt(e[0],10),t.length));let c=t.length-s,r="";for(let o=c;o<t.length;o++){let y=(o+1).toString().padStart(5," ");r+=`${y} ${t[o]}
|
|
2
|
+
`}return{stdout:r,stderr:"",exitCode:0}}};export{m as historyCommand};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{a as c,b as u,c as h}from"./chunk-74CEPOFO.js";import f from"turndown";var p={name:"html-to-markdown",summary:"convert HTML to Markdown (BashEnv extension)",usage:"html-to-markdown [OPTION]... [FILE]",description:["Convert HTML content to Markdown format using the turndown library.","This is a non-standard BashEnv extension command, not available in regular bash.","","Read HTML from FILE or standard input and output Markdown to standard output.","Commonly used with curl to convert web pages:"," curl -s https://example.com | html-to-markdown","","Supported HTML elements:"," - Headings (h1-h6) \u2192 # Markdown headings"," - Paragraphs (p) \u2192 Plain text with blank lines"," - Links (a) \u2192 [text](url)"," - Images (img) \u2192 "," - Bold/Strong \u2192 **text**"," - Italic/Em \u2192 _text_"," - Code (code, pre) \u2192 `inline` or fenced blocks"," - Lists (ul, ol, li) \u2192 - or 1. items"," - Blockquotes \u2192 > quoted text"," - Horizontal rules (hr) \u2192 ---"],options:["-b, --bullet=CHAR bullet character for unordered lists (-, +, or *)","-c, --code=FENCE fence style for code blocks (``` or ~~~)","-r, --hr=STRING string for horizontal rules (default: ---)"," --heading-style=STYLE"," heading style: 'atx' for # headings (default),"," 'setext' for underlined headings (h1/h2 only)"," --help display this help and exit"],examples:["echo '<h1>Hello</h1><p>World</p>' | html-to-markdown","html-to-markdown page.html","curl -s https://example.com | html-to-markdown > page.md"]},g={name:"html-to-markdown",async execute(r,n){if(u(r))return c(p);let s="-",a="```",i="---",m="atx",o=[];for(let t=0;t<r.length;t++){let e=r[t];if(e==="-b"||e==="--bullet")s=r[++t]??"-";else if(e.startsWith("--bullet="))s=e.slice(9);else if(e==="-c"||e==="--code")a=r[++t]??"```";else if(e.startsWith("--code="))a=e.slice(7);else if(e==="-r"||e==="--hr")i=r[++t]??"---";else if(e.startsWith("--hr="))i=e.slice(5);else if(e.startsWith("--heading-style=")){let d=e.slice(16);(d==="setext"||d==="atx")&&(m=d)}else if(e==="-")o.push("-");else{if(e.startsWith("--"))return h("html-to-markdown",e);if(e.startsWith("-"))return h("html-to-markdown",e);o.push(e)}}let l;if(o.length===0||o.length===1&&o[0]==="-")l=n.stdin;else try{let t=n.fs.resolvePath(n.cwd,o[0]);l=await n.fs.readFile(t)}catch{return{stdout:"",stderr:`html-to-markdown: ${o[0]}: No such file or directory
|
|
2
|
+
`,exitCode:1}}if(!l.trim())return{stdout:"",stderr:"",exitCode:0};try{let t=new f({bulletListMarker:s,codeBlockStyle:"fenced",fence:a,hr:i,headingStyle:m});return t.remove(["script","style","footer"]),{stdout:`${t.turndown(l).trim()}
|
|
3
|
+
`,stderr:"",exitCode:0}}catch(t){return{stdout:"",stderr:`html-to-markdown: conversion error: ${t.message}
|
|
4
|
+
`,exitCode:1}}}};export{g as htmlToMarkdownCommand};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{a as b,b as $,c as d}from"./chunk-74CEPOFO.js";var O={name:"jq",summary:"command-line JSON processor",usage:"jq [OPTIONS] FILTER [FILE]",options:["-r, --raw-output output strings without quotes","-c, --compact compact output (no pretty printing)","-e, --exit-status set exit status based on output","-s, --slurp read entire input into array","-n, --null-input don't read any input"," --help display this help and exit"]};function g(r,f,t,e=0){if(r===null||r===void 0)return"null";if(typeof r=="boolean"||typeof r=="number")return String(r);if(typeof r=="string")return t?r:JSON.stringify(r);if(Array.isArray(r))return r.length===0?"[]":f?`[${r.map(l=>g(l,!0,!1)).join(",")}]`:`[
|
|
2
|
+
${r.map(l=>" ".repeat(e+1)+g(l,!1,!1,e+1)).join(`,
|
|
3
|
+
`)}
|
|
4
|
+
${" ".repeat(e)}]`;if(typeof r=="object"){let s=Object.keys(r);return s.length===0?"{}":f?`{${s.map(i=>`${JSON.stringify(i)}:${g(r[i],!0,!1)}`).join(",")}}`:`{
|
|
5
|
+
${s.map(i=>{let n=g(r[i],!1,!1,e+1);return`${" ".repeat(e+1)}${JSON.stringify(i)}: ${n}`}).join(`,
|
|
6
|
+
`)}
|
|
7
|
+
${" ".repeat(e)}}`}return String(r)}function m(r,f){if(f===""||f===".")return[r];let t=f.startsWith(".")?f.slice(1):f;if(t==="")return[r];if(t.startsWith("[]")){let i=t.slice(2);return Array.isArray(r)?r.flatMap(n=>m(n,`.${i}`)):r&&typeof r=="object"?Object.values(r).flatMap(n=>m(n,`.${i}`)):[]}let e=t.match(/^\[(-?\d+)\](.*)/);if(e){let i=Number.parseInt(e[1],10),n=e[2];if(Array.isArray(r)){let h=i<0?r.length+i:i;if(h>=0&&h<r.length)return m(r[h],`.${n}`)}return[null]}let s=t.match(/^([a-zA-Z_][a-zA-Z0-9_]*)(.*)/);if(s){let i=s[1],n=s[2];if(r&&typeof r=="object"&&!Array.isArray(r)){let o=r[i];if(n.startsWith("[]"))return n=n.slice(2),Array.isArray(o)?o.flatMap(c=>m(c,`.${n}`)):o&&typeof o=="object"?Object.values(o).flatMap(c=>m(c,`.${n}`)):[];if(n.startsWith(".")||n.startsWith("[")||n==="")return m(o,n||".")}return[null]}let l=t.match(/^\["([^"]+)"\](.*)/);if(l){let i=l[1],n=l[2];return r&&typeof r=="object"&&!Array.isArray(r)?m(r[i],`.${n}`):[null]}return[null]}function j(r,f){let t=f.trim();if(t.includes("|")){let e=t.split("|").map(l=>l.trim()),s=[r];for(let l of e)s=s.flatMap(i=>j(i,l));return s}return t==="keys"?Array.isArray(r)?[r.map((e,s)=>s)]:r&&typeof r=="object"?[Object.keys(r)]:[null]:t==="values"?Array.isArray(r)?[r]:r&&typeof r=="object"?[Object.values(r)]:[null]:t==="length"?typeof r=="string"?[r.length]:Array.isArray(r)?[r.length]:r&&typeof r=="object"?[Object.keys(r).length]:r===null?[0]:[null]:t==="type"?r===null?["null"]:Array.isArray(r)?["array"]:[typeof r]:t==="first"?Array.isArray(r)&&r.length>0?[r[0]]:[null]:t==="last"?Array.isArray(r)&&r.length>0?[r[r.length-1]]:[null]:t==="reverse"?Array.isArray(r)?[[...r].reverse()]:typeof r=="string"?[r.split("").reverse().join("")]:[null]:t==="sort"?Array.isArray(r)?[[...r].sort()]:[null]:t==="unique"?Array.isArray(r)?[[...new Set(r.map(e=>JSON.stringify(e)))].map(e=>JSON.parse(e))]:[null]:t==="flatten"?Array.isArray(r)?[r.flat()]:[null]:t==="add"?Array.isArray(r)?r.length===0?[null]:r.every(e=>typeof e=="number")?[r.reduce((e,s)=>e+s,0)]:r.every(e=>typeof e=="string")?[r.join("")]:r.every(e=>Array.isArray(e))?[r.flat()]:[null]:[null]:t==="min"?Array.isArray(r)&&r.length>0?[Math.min(...r)]:[null]:t==="max"?Array.isArray(r)&&r.length>0?[Math.max(...r)]:[null]:t==="empty"?[]:t==="not"?[!r]:m(r,t)}var x={name:"jq",async execute(r,f){if($(r))return b(O);let t=!1,e=!1,s=!1,l=!1,i=!1,n=".",h=!1,o=[];for(let a=0;a<r.length;a++){let u=r[a];if(u==="-r"||u==="--raw-output")t=!0;else if(u==="-c"||u==="--compact-output")e=!0;else if(u==="-e"||u==="--exit-status")s=!0;else if(u==="-s"||u==="--slurp")l=!0;else if(u==="-n"||u==="--null-input")i=!0;else if(u==="-")o.push("-");else{if(u.startsWith("--"))return d("jq",u);if(u.startsWith("-"))for(let p of u.slice(1))if(p==="r")t=!0;else if(p==="c")e=!0;else if(p==="e")s=!0;else if(p==="s")l=!0;else if(p==="n")i=!0;else return d("jq",`-${p}`);else h?o.push(u):(n=u,h=!0)}}let c;if(i)c="";else if(o.length===0||o.length===1&&o[0]==="-")c=f.stdin;else try{let a=f.fs.resolvePath(f.cwd,o[0]);c=await f.fs.readFile(a)}catch{return{stdout:"",stderr:`jq: ${o[0]}: No such file or directory
|
|
8
|
+
`,exitCode:2}}try{let a;if(i)a=j(null,n);else if(l){let y=[];for(let A of c.trim().split(`
|
|
9
|
+
`))A.trim()&&y.push(JSON.parse(A));a=j(y,n)}else{let y=c.trim();if(y.startsWith("{")||y.startsWith("["))a=j(JSON.parse(y),n);else{a=[];for(let A of y.split(`
|
|
10
|
+
`))A.trim()&&a.push(...j(JSON.parse(A),n))}}let u=a.map(y=>g(y,e,t)).join(`
|
|
11
|
+
`),p=s&&(a.length===0||a.every(y=>y==null||y===!1))?1:0;return{stdout:u?`${u}
|
|
12
|
+
`:"",stderr:"",exitCode:p}}catch(a){return{stdout:"",stderr:`jq: parse error: ${a.message}
|
|
13
|
+
`,exitCode:5}}}};export{x as jqCommand};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{a as m,b as h}from"./chunk-74CEPOFO.js";var y={name:"ln",summary:"make links between files",usage:"ln [OPTIONS] TARGET LINK_NAME",options:["-s create a symbolic link instead of a hard link","-f remove existing destination files","-n treat LINK_NAME as a normal file if it is a symbolic link to a directory","-v print name of each linked file"," --help display this help and exit"]},p={name:"ln",async execute(i,s){if(h(i))return m(y);let r=!1,a=!1,d=!1,t=0;for(;t<i.length&&i[t].startsWith("-");){let e=i[t];if(e==="-s"||e==="--symbolic")r=!0,t++;else if(e==="-f"||e==="--force")a=!0,t++;else if(e==="-v"||e==="--verbose")d=!0,t++;else if(e==="-n"||e==="--no-dereference")t++;else if(/^-[sfvn]+$/.test(e))e.includes("s")&&(r=!0),e.includes("f")&&(a=!0),e.includes("v")&&(d=!0),t++;else if(e==="--"){t++;break}else return{stdout:"",stderr:`ln: invalid option -- '${e.slice(1)}'
|
|
2
|
+
`,exitCode:1}}let f=i.slice(t);if(f.length<2)return{stdout:"",stderr:`ln: missing file operand
|
|
3
|
+
`,exitCode:1};let n=f[0],l=f[1],o=s.fs.resolvePath(s.cwd,l);if(await s.fs.exists(o))if(a)try{await s.fs.rm(o,{force:!0})}catch{return{stdout:"",stderr:`ln: cannot remove '${l}': Permission denied
|
|
4
|
+
`,exitCode:1}}else return{stdout:"",stderr:`ln: failed to create ${r?"symbolic ":""}link '${l}': File exists
|
|
5
|
+
`,exitCode:1};try{if(r)await s.fs.symlink(n,o);else{let e=s.fs.resolvePath(s.cwd,n);if(!await s.fs.exists(e))return{stdout:"",stderr:`ln: failed to access '${n}': No such file or directory
|
|
6
|
+
`,exitCode:1};await s.fs.link(e,o)}}catch(e){let u=e;return u.message.includes("EPERM")?{stdout:"",stderr:`ln: '${n}': hard link not allowed for directory
|
|
7
|
+
`,exitCode:1}:{stdout:"",stderr:`ln: ${u.message}
|
|
8
|
+
`,exitCode:1}}let c="";return d&&(c=`'${l}' -> '${n}'
|
|
9
|
+
`),{stdout:c,stderr:"",exitCode:0}}};export{p as lnCommand};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import{a as M}from"./chunk-ZVV5VXYZ.js";import{a as C,b as A}from"./chunk-74CEPOFO.js";import{minimatch as F}from"minimatch";function v(r){if(r<1024)return String(r);if(r<1024*1024){let e=r/1024;return e<10?`${e.toFixed(1)}K`:`${Math.round(e)}K`}if(r<1024*1024*1024){let e=r/1048576;return e<10?`${e.toFixed(1)}M`:`${Math.round(e)}M`}let o=r/(1024*1024*1024);return o<10?`${o.toFixed(1)}G`:`${Math.round(o)}G`}function D(r){let e=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][r.getMonth()],h=String(r.getDate()).padStart(2," "),m=new Date,d=new Date(m.getTime()-4320*60*60*1e3);if(r>d){let p=String(r.getHours()).padStart(2,"0"),y=String(r.getMinutes()).padStart(2,"0");return`${e} ${h} ${p}:${y}`}let $=r.getFullYear();return`${e} ${h} ${$}`}var O={name:"ls",summary:"list directory contents",usage:"ls [OPTION]... [FILE]...",options:["-a, --all do not ignore entries starting with .","-A, --almost-all do not list . and ..","-d, --directory list directories themselves, not their contents","-h, --human-readable with -l, print sizes like 1K 234M 2G etc.","-l use a long listing format","-r, --reverse reverse order while sorting","-R, --recursive list subdirectories recursively","-S sort by file size, largest first","-t sort by time, newest first","-1 list one file per line"," --help display this help and exit"]},W={showAll:{short:"a",long:"all",type:"boolean"},showAlmostAll:{short:"A",long:"almost-all",type:"boolean"},longFormat:{short:"l",type:"boolean"},humanReadable:{short:"h",long:"human-readable",type:"boolean"},recursive:{short:"R",long:"recursive",type:"boolean"},reverse:{short:"r",long:"reverse",type:"boolean"},sortBySize:{short:"S",type:"boolean"},directoryOnly:{short:"d",long:"directory",type:"boolean"},sortByTime:{short:"t",type:"boolean"},onePerLine:{short:"1",type:"boolean"}},j={name:"ls",async execute(r,o){if(A(r))return C(O);let e=M("ls",r,W);if(!e.ok)return e.error;let h=e.result.flags.showAll,m=e.result.flags.showAlmostAll,d=e.result.flags.longFormat,$=e.result.flags.humanReadable,p=e.result.flags.recursive,y=e.result.flags.reverse,g=e.result.flags.sortBySize,z=e.result.flags.directoryOnly,f=e.result.flags.sortByTime;e.result.flags.onePerLine;let s=e.result.positional;s.length===0&&s.push(".");let n="",i="",c=0;for(let t=0;t<s.length;t++){let a=s[t];if(t>0&&n&&!n.endsWith(`
|
|
2
|
+
|
|
3
|
+
`)&&(n+=`
|
|
4
|
+
`),z){let l=o.fs.resolvePath(o.cwd,a);try{let u=await o.fs.stat(l);if(d){let w=u.isDirectory?"drwxr-xr-x":"-rw-r--r--",S=u.isDirectory?"/":"",P=u.size??0,b=$?v(P).padStart(5):String(P).padStart(5),x=u.mtime??new Date(0),J=D(x);n+=`${w} 1 user user ${b} ${J} ${a}${S}
|
|
5
|
+
`}else n+=`${a}
|
|
6
|
+
`}catch{i+=`ls: cannot access '${a}': No such file or directory
|
|
7
|
+
`,c=2}continue}if(a.includes("*")||a.includes("?")||a.includes("[")){let l=await B(a,o,h,m,d,y,$,g);n+=l.stdout,i+=l.stderr,l.exitCode!==0&&(c=l.exitCode)}else{let l=await H(a,o,h,m,d,p,s.length>1,y,$,g);n+=l.stdout,i+=l.stderr,l.exitCode!==0&&(c=l.exitCode)}}return{stdout:n,stderr:i,exitCode:c}}};async function B(r,o,e,h,m,d=!1,$=!1,p=!1){let y=e||h,g=o.fs.getAllPaths(),z=o.fs.resolvePath(o.cwd,"."),f=[];for(let s of g){let n=s.startsWith(z)&&s.slice(z.length+1)||s;if(F(n,r)||F(s,r)){let i=n.split("/").pop()||n;if(!y&&i.startsWith("."))continue;f.push(n||s)}}if(f.length===0)return{stdout:"",stderr:`ls: ${r}: No such file or directory
|
|
8
|
+
`,exitCode:2};if(p){let s=[];for(let n of f){let i=o.fs.resolvePath(o.cwd,n);try{let c=await o.fs.stat(i);s.push({path:n,size:c.size??0})}catch{s.push({path:n,size:0})}}s.sort((n,i)=>i.size-n.size),f.length=0,f.push(...s.map(n=>n.path))}else f.sort();if(d&&f.reverse(),m){let s=[];for(let n of f){let i=o.fs.resolvePath(o.cwd,n);try{let c=await o.fs.stat(i),t=c.isDirectory?"drwxr-xr-x":"-rw-r--r--",a=c.isDirectory?"/":"",l=c.size??0,u=$?v(l).padStart(5):String(l).padStart(5),w=c.mtime??new Date(0),S=D(w);s.push(`${t} 1 user user ${u} ${S} ${n}${a}`)}catch{s.push(`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${n}`)}}return{stdout:`${s.join(`
|
|
9
|
+
`)}
|
|
10
|
+
`,stderr:"",exitCode:0}}return{stdout:`${f.join(`
|
|
11
|
+
`)}
|
|
12
|
+
`,stderr:"",exitCode:0}}async function H(r,o,e,h,m,d,$,p=!1,y=!1,g=!1,z=!1){let f=e||h,s=o.fs.resolvePath(o.cwd,r);try{let n=await o.fs.stat(s);if(!n.isDirectory){if(m){let t=n.size??0,a=y?v(t).padStart(5):String(t).padStart(5),l=n.mtime??new Date(0),u=D(l);return{stdout:`-rw-r--r-- 1 user user ${a} ${u} ${r}
|
|
13
|
+
`,stderr:"",exitCode:0}}return{stdout:`${r}
|
|
14
|
+
`,stderr:"",exitCode:0}}let i=await o.fs.readdir(s);if(f||(i=i.filter(t=>!t.startsWith("."))),g){let t=[];for(let a of i){let l=s==="/"?`/${a}`:`${s}/${a}`;try{let u=await o.fs.stat(l);t.push({name:a,size:u.size??0})}catch{t.push({name:a,size:0})}}t.sort((a,l)=>l.size-a.size),i=t.map(a=>a.name)}else i.sort();e&&(i=[".","..",...i]),p&&i.reverse();let c="";if((d||$)&&(c+=`${r}:
|
|
15
|
+
`),m){c+=`total ${i.length}
|
|
16
|
+
`;for(let t of i){if(t==="."||t===".."){c+=`drwxr-xr-x 1 user user 0 Jan 1 00:00 ${t}
|
|
17
|
+
`;continue}let a=s==="/"?`/${t}`:`${s}/${t}`;try{let l=await o.fs.stat(a),u=l.isDirectory?"drwxr-xr-x":"-rw-r--r--",w=l.isDirectory?"/":"",S=l.size??0,P=y?v(S).padStart(5):String(S).padStart(5),b=l.mtime??new Date(0),x=D(b);c+=`${u} 1 user user ${P} ${x} ${t}${w}
|
|
18
|
+
`}catch{c+=`-rw-r--r-- 1 user user 0 Jan 1 00:00 ${t}
|
|
19
|
+
`}}}else c+=i.join(`
|
|
20
|
+
`)+(i.length?`
|
|
21
|
+
`:"");if(d)for(let t of i){if(t==="."||t==="..")continue;let a=s==="/"?`/${t}`:`${s}/${t}`;try{if((await o.fs.stat(a)).isDirectory){c+=`
|
|
22
|
+
`;let u=r==="."?`./${t}`:`${r}/${t}`,w=await H(u,o,e,h,m,d,!1,p,y,g,!0);c+=w.stdout}}catch{}}return{stdout:c,stderr:"",exitCode:0}}catch{return{stdout:"",stderr:`ls: ${r}: No such file or directory
|
|
23
|
+
`,exitCode:2}}}export{j as lsCommand};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a}from"./chunk-ZVV5VXYZ.js";import{a as l}from"./chunk-44UOCSGV.js";import"./chunk-74CEPOFO.js";var g={recursive:{short:"p",long:"parents",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},y={name:"mkdir",async execute(u,o){let e=a("mkdir",u,g);if(!e.ok)return e.error;let m=e.result.flags.recursive,f=e.result.flags.verbose,n=e.result.positional;if(n.length===0)return{stdout:"",stderr:`mkdir: missing operand
|
|
2
|
+
`,exitCode:1};let c="",t="",d=0;for(let r of n)try{let i=o.fs.resolvePath(o.cwd,r);await o.fs.mkdir(i,{recursive:m}),f&&(c+=`mkdir: created directory '${r}'
|
|
3
|
+
`)}catch(i){let s=l(i);s.includes("ENOENT")||s.includes("no such file")?t+=`mkdir: cannot create directory '${r}': No such file or directory
|
|
4
|
+
`:s.includes("EEXIST")||s.includes("already exists")?t+=`mkdir: cannot create directory '${r}': File exists
|
|
5
|
+
`:t+=`mkdir: cannot create directory '${r}': ${s}
|
|
6
|
+
`,d=1}return{stdout:c,stderr:t,exitCode:d}}};export{y as mkdirCommand};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as y}from"./chunk-ZVV5VXYZ.js";import{a as $}from"./chunk-44UOCSGV.js";import{a as g,b as u}from"./chunk-74CEPOFO.js";var C={name:"mv",summary:"move (rename) files",usage:"mv [OPTION]... SOURCE... DEST",options:["-f, --force do not prompt before overwriting","-n, --no-clobber do not overwrite an existing file","-v, --verbose explain what is being done"," --help display this help and exit"]},P={force:{short:"f",long:"force",type:"boolean"},noClobber:{short:"n",long:"no-clobber",type:"boolean"},verbose:{short:"v",long:"verbose",type:"boolean"}},O={name:"mv",async execute(m,t){if(u(m))return g(C);let s=y("mv",m,P);if(!s.ok)return s.error;let p=s.result.flags.force,d=s.result.flags.noClobber,w=s.result.flags.verbose,l=s.result.positional;if(d&&(p=!1),l.length<2)return{stdout:"",stderr:`mv: missing destination file operand
|
|
2
|
+
`,exitCode:1};let r=l.pop()??"",v=l,n=t.fs.resolvePath(t.cwd,r),h="",c="",b=0,a=!1;try{a=(await t.fs.stat(n)).isDirectory}catch{}if(v.length>1&&!a)return{stdout:"",stderr:`mv: target '${r}' is not a directory
|
|
3
|
+
`,exitCode:1};for(let e of v)try{let f=t.fs.resolvePath(t.cwd,e),o=n;if(a){let i=e.split("/").pop()||e;o=n==="/"?`/${i}`:`${n}/${i}`}if(d)try{await t.fs.stat(o);continue}catch{}if(await t.fs.mv(f,o),w){let i=a?`${r}/${e.split("/").pop()||e}`:r;h+=`renamed '${e}' -> '${i}'
|
|
4
|
+
`}}catch(f){let o=$(f);o.includes("ENOENT")||o.includes("no such file")?c+=`mv: cannot stat '${e}': No such file or directory
|
|
5
|
+
`:c+=`mv: cannot move '${e}': ${o}
|
|
6
|
+
`,b=1}return{stdout:h,stderr:c,exitCode:b}}};export{O as mvCommand};
|