@poe-platform/safe-bash 0.1.629 → 0.1.631
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/office-package/compression.d.ts +19 -0
- package/dist/office-package/compression.js +186 -0
- package/dist/office-package/runtime.d.ts +11 -0
- package/dist/office-package/runtime.js +28 -0
- package/dist/safe-bash/chunks/{bz2-B2RXT4EX.js → bz2-ACU4EOVE.js} +2 -2
- package/dist/safe-bash/chunks/chunk-2E4KBFO6.js +239 -0
- package/dist/safe-bash/chunks/chunk-2E4KBFO6.js.map +7 -0
- package/dist/safe-bash/chunks/chunk-3E5M2WEL.js +33 -0
- package/dist/safe-bash/chunks/chunk-3E5M2WEL.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-WPEMUXV4.js → chunk-3LD67SER.js} +12 -10
- package/dist/safe-bash/chunks/{chunk-WPEMUXV4.js.map → chunk-3LD67SER.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-6LSSEOG7.js → chunk-6HNK7Q66.js} +11 -7
- package/dist/safe-bash/chunks/{chunk-6LSSEOG7.js.map → chunk-6HNK7Q66.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-AD7UAP5B.js → chunk-7EEWZY5S.js} +10 -8
- package/dist/safe-bash/chunks/{chunk-AD7UAP5B.js.map → chunk-7EEWZY5S.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-RNKTWFEM.js → chunk-CDBQXRWL.js} +3 -3
- package/dist/safe-bash/chunks/{chunk-UYX72YHY.js → chunk-CHHAB5SS.js} +10 -74
- package/dist/safe-bash/chunks/{chunk-UYX72YHY.js.map → chunk-CHHAB5SS.js.map} +3 -3
- package/dist/safe-bash/chunks/{chunk-KYNRHYHP.js → chunk-EI4X5ETX.js} +15 -13
- package/dist/safe-bash/chunks/{chunk-KYNRHYHP.js.map → chunk-EI4X5ETX.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-KZ7QCYNT.js → chunk-GIBLUW2U.js} +13 -9
- package/dist/safe-bash/chunks/{chunk-KZ7QCYNT.js.map → chunk-GIBLUW2U.js.map} +1 -1
- package/dist/safe-bash/chunks/chunk-GPV7ZFYS.js +1528 -0
- package/dist/safe-bash/chunks/chunk-GPV7ZFYS.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-N5CYTGBN.js → chunk-H3E67KTZ.js} +13 -9
- package/dist/safe-bash/chunks/{chunk-N5CYTGBN.js.map → chunk-H3E67KTZ.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-AFH57PPL.js → chunk-IEKESMO4.js} +3 -3
- package/dist/safe-bash/chunks/{chunk-DPJWEGIX.js → chunk-JLBIUYT3.js} +2 -2
- package/dist/safe-bash/chunks/chunk-JZDO5MC3.js +77 -0
- package/dist/safe-bash/chunks/chunk-JZDO5MC3.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-GFZKQIPL.js → chunk-LA6BX562.js} +8 -6
- package/dist/safe-bash/chunks/{chunk-GFZKQIPL.js.map → chunk-LA6BX562.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-PVJJFCGA.js → chunk-M3GPCYSP.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-FWDMJTQO.js → chunk-NDCZ3UBP.js} +13 -9
- package/dist/safe-bash/chunks/{chunk-FWDMJTQO.js.map → chunk-NDCZ3UBP.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-2KL6W6NB.js → chunk-O2EVBRKF.js} +1 -2
- package/dist/safe-bash/chunks/chunk-OFT77XIB.js +389 -0
- package/dist/safe-bash/chunks/chunk-OFT77XIB.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-PCLOK32J.js → chunk-PC6BEIAF.js} +13 -9
- package/dist/safe-bash/chunks/{chunk-PCLOK32J.js.map → chunk-PC6BEIAF.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-3M5F7LD5.js → chunk-QWKP7ZU7.js} +13 -9
- package/dist/safe-bash/chunks/{chunk-3M5F7LD5.js.map → chunk-QWKP7ZU7.js.map} +1 -1
- package/dist/safe-bash/chunks/chunk-THXJ6CLF.js +53 -0
- package/dist/safe-bash/chunks/chunk-THXJ6CLF.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-HHJSJWUD.js → chunk-V73A742N.js} +57 -15
- package/dist/safe-bash/chunks/chunk-V73A742N.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-4BYUV5PA.js → chunk-VN3ZGME3.js} +12 -8
- package/dist/safe-bash/chunks/{chunk-4BYUV5PA.js.map → chunk-VN3ZGME3.js.map} +1 -1
- package/dist/safe-bash/chunks/chunk-WECHUK3Y.js +4285 -0
- package/dist/safe-bash/chunks/chunk-WECHUK3Y.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-X55AMTNM.js → chunk-WIOEUR7D.js} +14 -10
- package/dist/safe-bash/chunks/{chunk-X55AMTNM.js.map → chunk-WIOEUR7D.js.map} +1 -1
- package/dist/safe-bash/chunks/chunk-WPIOO4NX.js +443 -0
- package/dist/safe-bash/chunks/chunk-WPIOO4NX.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-C7QNJ3D4.js → chunk-WYTI64IU.js} +2 -2
- package/dist/safe-bash/chunks/{xz-AVXFDXW4.js → xz-U4QDTPZL.js} +2 -2
- package/dist/safe-bash/chunks/{zstd-R6RPHJYO.js → zstd-OG5RPYXO.js} +2 -2
- package/dist/safe-bash/commands/archive/zip/crc.d.ts +2 -0
- package/dist/safe-bash/commands/archive/zip/crc.d.ts.map +1 -0
- package/dist/safe-bash/commands/archive/zip/crc.js +7 -0
- package/dist/safe-bash/commands/archive/zip/crc.js.map +1 -0
- package/dist/safe-bash/commands/archive/zip/crypto.d.ts +4 -0
- package/dist/safe-bash/commands/archive/zip/crypto.d.ts.map +1 -0
- package/dist/safe-bash/commands/archive/zip/crypto.js +34 -0
- package/dist/safe-bash/commands/archive/zip/crypto.js.map +1 -0
- package/dist/safe-bash/commands/archive/zip/help.d.ts +3 -0
- package/dist/safe-bash/commands/archive/zip/help.d.ts.map +1 -0
- package/dist/safe-bash/commands/archive/zip/help.js +87 -0
- package/dist/safe-bash/commands/archive/zip/help.js.map +1 -0
- package/dist/safe-bash/commands/archive/zip/move.d.ts +12 -0
- package/dist/safe-bash/commands/archive/zip/move.d.ts.map +1 -0
- package/dist/safe-bash/commands/archive/zip/move.js +60 -0
- package/dist/safe-bash/commands/archive/zip/move.js.map +1 -0
- package/dist/safe-bash/commands/archive/zip/options.js +5 -5
- package/dist/safe-bash/commands/archive/zip/options.js.map +1 -1
- package/dist/safe-bash/commands/archive/zip-format.d.ts +1 -1
- package/dist/safe-bash/commands/archive/zip-format.d.ts.map +1 -1
- package/dist/safe-bash/commands/archive/zip-format.js +14 -17
- package/dist/safe-bash/commands/archive/zip-format.js.map +1 -1
- package/dist/safe-bash/commands/archive/zip.d.ts.map +1 -1
- package/dist/safe-bash/commands/archive/zip.js +45 -15
- package/dist/safe-bash/commands/archive/zip.js.map +1 -1
- package/dist/safe-bash/commands/bytes/compression/bounded-codec.d.ts +2 -0
- package/dist/safe-bash/commands/bytes/compression/bounded-codec.d.ts.map +1 -1
- package/dist/safe-bash/commands/bytes/compression/bounded-codec.js +4 -0
- package/dist/safe-bash/commands/bytes/compression/bounded-codec.js.map +1 -1
- package/dist/safe-bash/commands/bytes/compression/codec.d.ts +4 -24
- package/dist/safe-bash/commands/bytes/compression/codec.d.ts.map +1 -1
- package/dist/safe-bash/commands/bytes/compression/codec.js +12 -168
- package/dist/safe-bash/commands/bytes/compression/codec.js.map +1 -1
- package/dist/safe-bash/commands/cmp.js +1 -1
- package/dist/safe-bash/commands/cmp.js.map +1 -1
- package/dist/safe-bash/commands/csplit/index.browser.js +10 -7
- package/dist/safe-bash/commands/docx/index.browser.js +54 -0
- package/dist/safe-bash/commands/docx/index.browser.js.map +7 -0
- package/dist/safe-bash/commands/docx/index.d.ts +25 -0
- package/dist/safe-bash/commands/docx/index.d.ts.map +1 -0
- package/dist/safe-bash/commands/docx/index.js +42 -0
- package/dist/safe-bash/commands/docx/index.js.map +1 -0
- package/dist/safe-bash/commands/docx/io.d.ts +15 -0
- package/dist/safe-bash/commands/docx/io.d.ts.map +1 -0
- package/dist/safe-bash/commands/docx/io.js +16 -0
- package/dist/safe-bash/commands/docx/io.js.map +1 -0
- package/dist/safe-bash/commands/factor/index.browser.js +7 -5
- package/dist/safe-bash/commands/filesystem.d.ts.map +1 -1
- package/dist/safe-bash/commands/filesystem.js +9 -1
- package/dist/safe-bash/commands/filesystem.js.map +1 -1
- package/dist/safe-bash/commands/getopt/index.browser.js +7 -5
- package/dist/safe-bash/commands/hexdump/index.browser.js +8 -6
- package/dist/safe-bash/commands/iconv/index.browser.js +8 -6
- package/dist/safe-bash/commands/line-endings/index.browser.js +10 -7
- package/dist/safe-bash/commands/llm/index.browser.js +10 -8
- package/dist/safe-bash/commands/llm/providers/index.browser.js +3 -3
- package/dist/safe-bash/commands/network/index.browser.js +11 -8
- package/dist/safe-bash/commands/node/browser.d.ts +2 -0
- package/dist/safe-bash/commands/node/browser.d.ts.map +1 -0
- package/dist/safe-bash/commands/node/browser.js +2 -0
- package/dist/safe-bash/commands/node/browser.js.map +1 -0
- package/dist/safe-bash/commands/node/index.browser.js +18 -0
- package/dist/safe-bash/commands/node/index.browser.js.map +7 -0
- package/dist/safe-bash/commands/node/safejs.d.ts +6 -0
- package/dist/safe-bash/commands/node/safejs.d.ts.map +1 -1
- package/dist/safe-bash/commands/node/safejs.js +25 -1
- package/dist/safe-bash/commands/node/safejs.js.map +1 -1
- package/dist/safe-bash/commands/op/index.browser.js +3 -3
- package/dist/safe-bash/commands/op/index.js +0 -1
- package/dist/safe-bash/commands/op/index.js.map +2 -2
- package/dist/safe-bash/commands/pptx/index.d.ts +29 -0
- package/dist/safe-bash/commands/pptx/index.d.ts.map +1 -0
- package/dist/safe-bash/commands/pptx/index.js +153 -0
- package/dist/safe-bash/commands/pptx/index.js.map +1 -0
- package/dist/safe-bash/commands/pr/index.browser.js +8 -6
- package/dist/safe-bash/commands/predicates.js +1 -1
- package/dist/safe-bash/commands/python/execution.d.ts +3 -0
- package/dist/safe-bash/commands/python/execution.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/execution.js +193 -0
- package/dist/safe-bash/commands/python/execution.js.map +1 -0
- package/dist/safe-bash/commands/python/index.browser.js +21 -0
- package/dist/safe-bash/commands/python/index.browser.js.map +7 -0
- package/dist/safe-bash/commands/python/index.d.ts +49 -0
- package/dist/safe-bash/commands/python/index.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/index.js +317 -0
- package/dist/safe-bash/commands/python/index.js.map +1 -0
- package/dist/safe-bash/commands/python/installation.d.ts +9 -0
- package/dist/safe-bash/commands/python/installation.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/installation.js +80 -0
- package/dist/safe-bash/commands/python/installation.js.map +1 -0
- package/dist/safe-bash/commands/python/invocation.d.ts +10 -0
- package/dist/safe-bash/commands/python/invocation.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/invocation.js +81 -0
- package/dist/safe-bash/commands/python/invocation.js.map +1 -0
- package/dist/safe-bash/commands/python/node.d.ts +12 -0
- package/dist/safe-bash/commands/python/node.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/node.js +33 -0
- package/dist/safe-bash/commands/python/node.js.map +1 -0
- package/dist/safe-bash/commands/python/provisioning-runtime.d.ts +5 -0
- package/dist/safe-bash/commands/python/provisioning-runtime.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/provisioning-runtime.js +179 -0
- package/dist/safe-bash/commands/python/provisioning-runtime.js.map +1 -0
- package/dist/safe-bash/commands/python/provisioning.d.ts +49 -0
- package/dist/safe-bash/commands/python/provisioning.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/provisioning.js +320 -0
- package/dist/safe-bash/commands/python/provisioning.js.map +1 -0
- package/dist/safe-bash/commands/python/reply.d.ts +3 -0
- package/dist/safe-bash/commands/python/reply.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/reply.js +103 -0
- package/dist/safe-bash/commands/python/reply.js.map +1 -0
- package/dist/safe-bash/commands/python/worker.browser.js +736 -0
- package/dist/safe-bash/commands/python/worker.browser.js.map +7 -0
- package/dist/safe-bash/commands/python/worker.d.ts +47 -0
- package/dist/safe-bash/commands/python/worker.d.ts.map +1 -0
- package/dist/safe-bash/commands/python/worker.js +373 -0
- package/dist/safe-bash/commands/python/worker.js.map +1 -0
- package/dist/safe-bash/commands/safejs/index.d.ts +5 -17
- package/dist/safe-bash/commands/safejs/index.d.ts.map +1 -1
- package/dist/safe-bash/commands/safejs/index.js +3 -202
- package/dist/safe-bash/commands/safejs/index.js.map +1 -1
- package/dist/safe-bash/commands/safejs/runtime.d.ts +15 -0
- package/dist/safe-bash/commands/safejs/runtime.d.ts.map +1 -0
- package/dist/safe-bash/commands/safejs/runtime.js +190 -0
- package/dist/safe-bash/commands/safejs/runtime.js.map +1 -0
- package/dist/safe-bash/commands/tsort/index.browser.js +8 -6
- package/dist/safe-bash/commands/xml/index.browser.js +9 -7
- package/dist/safe-bash/commands/yq/index.browser.js +10 -8
- package/dist/safe-bash/commands/yq/index.d.ts.map +1 -1
- package/dist/safe-bash/commands/yq/index.js +32 -4
- package/dist/safe-bash/commands/yq/index.js.map +1 -1
- package/dist/safe-bash/commands/yq/parser.d.ts.map +1 -1
- package/dist/safe-bash/commands/yq/parser.js +21 -5
- package/dist/safe-bash/commands/yq/parser.js.map +1 -1
- package/dist/safe-bash/contracts/command.d.ts +2 -0
- package/dist/safe-bash/contracts/command.d.ts.map +1 -1
- package/dist/safe-bash/contracts/command.js +6 -2
- package/dist/safe-bash/contracts/command.js.map +1 -1
- package/dist/safe-bash/contracts/filesystem-descriptor.d.ts +13 -0
- package/dist/safe-bash/contracts/filesystem-descriptor.d.ts.map +1 -0
- package/dist/safe-bash/contracts/filesystem-descriptor.js +189 -0
- package/dist/safe-bash/contracts/filesystem-descriptor.js.map +1 -0
- package/dist/safe-bash/contracts/filesystem-output-budget.d.ts +15 -0
- package/dist/safe-bash/contracts/filesystem-output-budget.d.ts.map +1 -0
- package/dist/safe-bash/contracts/filesystem-output-budget.js +69 -0
- package/dist/safe-bash/contracts/filesystem-output-budget.js.map +1 -0
- package/dist/safe-bash/contracts/filesystem-output.d.ts +11 -5
- package/dist/safe-bash/contracts/filesystem-output.d.ts.map +1 -1
- package/dist/safe-bash/contracts/filesystem-output.js +229 -20
- package/dist/safe-bash/contracts/filesystem-output.js.map +1 -1
- package/dist/safe-bash/contracts/io.d.ts +29 -0
- package/dist/safe-bash/contracts/io.d.ts.map +1 -1
- package/dist/safe-bash/contracts/io.js +317 -37
- package/dist/safe-bash/contracts/io.js.map +1 -1
- package/dist/safe-bash/core.browser.js +5963 -6522
- package/dist/safe-bash/core.browser.js.map +4 -4
- package/dist/safe-bash/core.d.ts +2 -0
- package/dist/safe-bash/core.d.ts.map +1 -1
- package/dist/safe-bash/core.js +2 -0
- package/dist/safe-bash/core.js.map +1 -1
- package/dist/safe-bash/index.d.ts +1 -0
- package/dist/safe-bash/index.d.ts.map +1 -1
- package/dist/safe-bash/index.js +1 -0
- package/dist/safe-bash/index.js.map +1 -1
- package/dist/safe-bash/opt-in/commands/cmp/compare.js +95 -0
- package/dist/safe-bash/opt-in/commands/cmp/index.d.ts +6 -0
- package/dist/safe-bash/opt-in/commands/cmp/index.js +99 -0
- package/dist/safe-bash/opt-in/commands/cmp/io.js +218 -0
- package/dist/safe-bash/opt-in/commands/cmp/options.d.ts +24 -0
- package/dist/safe-bash/opt-in/commands/cmp/options.js +195 -0
- package/dist/safe-bash/opt-in/commands/dd/conversions.js +152 -0
- package/dist/safe-bash/opt-in/commands/dd/index.d.ts +18 -0
- package/dist/safe-bash/opt-in/commands/dd/index.js +561 -0
- package/dist/safe-bash/opt-in/commands/dd/io.d.ts +31 -0
- package/dist/safe-bash/opt-in/commands/dd/io.js +244 -0
- package/dist/safe-bash/opt-in/commands/dd/options.js +184 -0
- package/dist/safe-bash/opt-in/commands/dd/report.js +69 -0
- package/dist/safe-bash/opt-in/commands/install/arguments.js +224 -0
- package/dist/safe-bash/opt-in/commands/install/index.d.ts +6 -0
- package/dist/safe-bash/opt-in/commands/install/index.js +678 -0
- package/dist/safe-bash/opt-in/commands/install/mode.js +71 -0
- package/dist/safe-bash/opt-in/commands/install/options.d.ts +36 -0
- package/dist/safe-bash/opt-in/commands/install/options.js +27 -0
- package/dist/safe-bash/opt-in/commands/shuf/args.js +179 -0
- package/dist/safe-bash/opt-in/commands/shuf/index.d.ts +6 -0
- package/dist/safe-bash/opt-in/commands/shuf/index.js +20 -0
- package/dist/safe-bash/opt-in/commands/shuf/input.js +93 -0
- package/dist/safe-bash/opt-in/commands/shuf/options.d.ts +9 -0
- package/dist/safe-bash/opt-in/commands/shuf/options.js +8 -0
- package/dist/safe-bash/opt-in/commands/shuf/random.js +114 -0
- package/dist/safe-bash/opt-in/commands/shuf/shuf.d.ts +3 -0
- package/dist/safe-bash/opt-in/commands/shuf/shuf.js +230 -0
- package/dist/safe-bash/opt-in/commands/shuf/usage.js +24 -0
- package/dist/safe-bash/opt-in/commands/truncate/arguments.js +186 -0
- package/dist/safe-bash/opt-in/commands/truncate/index.d.ts +9 -0
- package/dist/safe-bash/opt-in/commands/truncate/index.js +244 -0
- package/dist/safe-bash/opt-in/commands/yes/index.d.ts +11 -0
- package/dist/safe-bash/opt-in/commands/yes/index.js +167 -0
- package/dist/safe-bash/opt-in/commands/yq/arguments.js +177 -0
- package/dist/safe-bash/opt-in/commands/yq/evaluate.js +564 -0
- package/dist/safe-bash/opt-in/commands/yq/expression.js +183 -0
- package/dist/safe-bash/opt-in/commands/yq/inplace.js +65 -0
- package/dist/safe-bash/opt-in/commands/yq/mike.d.ts +9 -0
- package/dist/safe-bash/opt-in/commands/yq/mike.js +192 -0
- package/dist/safe-bash/opt-in/commands/yq/native-encoder.js +165 -0
- package/dist/safe-bash/opt-in/commands/yq/native-work.d.ts +44 -0
- package/dist/safe-bash/opt-in/commands/yq/native-work.js +188 -0
- package/dist/safe-bash/opt-in/commands/yq/nodes.js +621 -0
- package/dist/safe-bash/opt-in/entrypoints/arrays.d.ts +1 -0
- package/dist/safe-bash/opt-in/entrypoints/arrays.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/cmp.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/cmp.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/dd.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/dd.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/devices.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/devices.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/install.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/install.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/jobs.d.ts +1 -0
- package/dist/safe-bash/opt-in/entrypoints/jobs.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/mapfile.d.ts +1 -0
- package/dist/safe-bash/opt-in/entrypoints/mapfile.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/read.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/read.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/shuf.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/shuf.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/trap.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/trap.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/truncate.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/truncate.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/yes.d.ts +2 -0
- package/dist/safe-bash/opt-in/entrypoints/yes.js +1 -0
- package/dist/safe-bash/opt-in/entrypoints/yq.d.ts +3 -0
- package/dist/safe-bash/opt-in/entrypoints/yq.js +1 -0
- package/dist/safe-bash/opt-in/fs/devices/index.d.ts +8 -0
- package/dist/safe-bash/opt-in/fs/devices/index.js +292 -0
- package/dist/safe-bash/opt-in/optional.d.ts +28 -0
- package/dist/safe-bash/opt-in/optional.js +14 -0
- package/dist/safe-bash/opt-in/shell/extensions/arrays/index.d.ts +2 -0
- package/dist/safe-bash/opt-in/shell/extensions/arrays/index.js +4 -0
- package/dist/safe-bash/opt-in/shell/extensions/jobs/index.d.ts +2 -0
- package/dist/safe-bash/opt-in/shell/extensions/jobs/index.js +291 -0
- package/dist/safe-bash/opt-in/shell/extensions/jobs/state.js +374 -0
- package/dist/safe-bash/opt-in/shell/extensions/mapfile/index.d.ts +24 -0
- package/dist/safe-bash/opt-in/shell/extensions/mapfile/index.js +338 -0
- package/dist/safe-bash/opt-in/shell/extensions/read/index.d.ts +5 -0
- package/dist/safe-bash/opt-in/shell/extensions/read/index.js +351 -0
- package/dist/safe-bash/opt-in/shell/extensions/trap/index.d.ts +9 -0
- package/dist/safe-bash/opt-in/shell/extensions/trap/index.js +210 -0
- package/dist/safe-bash/optional-host.d.ts +5 -0
- package/dist/safe-bash/optional-host.d.ts.map +1 -0
- package/dist/safe-bash/optional-host.js +3 -0
- package/dist/safe-bash/optional-host.js.map +1 -0
- package/dist/safe-bash/shell/arrays/bindings.d.ts +15 -5
- package/dist/safe-bash/shell/arrays/bindings.d.ts.map +1 -1
- package/dist/safe-bash/shell/arrays/bindings.js +131 -23
- package/dist/safe-bash/shell/arrays/bindings.js.map +1 -1
- package/dist/safe-bash/shell/arrays/ledger.d.ts +1 -0
- package/dist/safe-bash/shell/arrays/ledger.d.ts.map +1 -1
- package/dist/safe-bash/shell/arrays/ledger.js +19 -0
- package/dist/safe-bash/shell/arrays/ledger.js.map +1 -1
- package/dist/safe-bash/shell/arrays/state.d.ts.map +1 -1
- package/dist/safe-bash/shell/arrays/state.js +3 -1
- package/dist/safe-bash/shell/arrays/state.js.map +1 -1
- package/dist/safe-bash/shell/arrays/syntax.d.ts +4 -1
- package/dist/safe-bash/shell/arrays/syntax.d.ts.map +1 -1
- package/dist/safe-bash/shell/arrays/syntax.js +3 -3
- package/dist/safe-bash/shell/arrays/syntax.js.map +1 -1
- package/dist/safe-bash/shell/conditional.js +1 -1
- package/dist/safe-bash/shell/descriptors.d.ts +31 -0
- package/dist/safe-bash/shell/descriptors.d.ts.map +1 -0
- package/dist/safe-bash/shell/descriptors.js +234 -0
- package/dist/safe-bash/shell/descriptors.js.map +1 -0
- package/dist/safe-bash/shell/diagnostic-name-ranges.d.ts +2 -0
- package/dist/safe-bash/shell/diagnostic-name-ranges.d.ts.map +1 -0
- package/dist/safe-bash/shell/diagnostic-name-ranges.js +717 -0
- package/dist/safe-bash/shell/diagnostic-name-ranges.js.map +1 -0
- package/dist/safe-bash/shell/diagnostic-name.d.ts +3 -0
- package/dist/safe-bash/shell/diagnostic-name.d.ts.map +1 -0
- package/dist/safe-bash/shell/diagnostic-name.js +89 -0
- package/dist/safe-bash/shell/diagnostic-name.js.map +1 -0
- package/dist/safe-bash/shell/display.js +1 -1
- package/dist/safe-bash/shell/display.js.map +1 -1
- package/dist/safe-bash/shell/extensions.d.ts +188 -0
- package/dist/safe-bash/shell/extensions.d.ts.map +1 -0
- package/dist/safe-bash/shell/extensions.js +141 -0
- package/dist/safe-bash/shell/extensions.js.map +1 -0
- package/dist/safe-bash/shell/input.d.ts +66 -14
- package/dist/safe-bash/shell/input.d.ts.map +1 -1
- package/dist/safe-bash/shell/input.js +947 -173
- package/dist/safe-bash/shell/input.js.map +1 -1
- package/dist/safe-bash/shell/parser.d.ts +38 -6
- package/dist/safe-bash/shell/parser.d.ts.map +1 -1
- package/dist/safe-bash/shell/parser.js +339 -52
- package/dist/safe-bash/shell/parser.js.map +1 -1
- package/dist/safe-bash/shell/runtime.d.ts +92 -20
- package/dist/safe-bash/shell/runtime.d.ts.map +1 -1
- package/dist/safe-bash/shell/runtime.js +2547 -689
- package/dist/safe-bash/shell/runtime.js.map +1 -1
- package/dist/safe-bash/shell/shell.d.ts.map +1 -1
- package/dist/safe-bash/shell/shell.js +52 -21
- package/dist/safe-bash/shell/shell.js.map +1 -1
- package/dist/safe-bash/shell/types.d.ts +4 -0
- package/dist/safe-bash/shell/types.d.ts.map +1 -1
- package/dist/safe-bash/shell/types.js.map +1 -1
- package/package.json +99 -5
- package/dist/safe-bash/chunks/chunk-4DBWBEU7.js +0 -194
- package/dist/safe-bash/chunks/chunk-4DBWBEU7.js.map +0 -7
- package/dist/safe-bash/chunks/chunk-CXMIIXJA.js +0 -178
- package/dist/safe-bash/chunks/chunk-CXMIIXJA.js.map +0 -7
- package/dist/safe-bash/chunks/chunk-HHJSJWUD.js.map +0 -7
- /package/dist/safe-bash/chunks/{bz2-B2RXT4EX.js.map → bz2-ACU4EOVE.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-RNKTWFEM.js.map → chunk-CDBQXRWL.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-AFH57PPL.js.map → chunk-IEKESMO4.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-DPJWEGIX.js.map → chunk-JLBIUYT3.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-PVJJFCGA.js.map → chunk-M3GPCYSP.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-2KL6W6NB.js.map → chunk-O2EVBRKF.js.map} +0 -0
- /package/dist/safe-bash/chunks/{chunk-C7QNJ3D4.js.map → chunk-WYTI64IU.js.map} +0 -0
- /package/dist/safe-bash/chunks/{xz-AVXFDXW4.js.map → xz-U4QDTPZL.js.map} +0 -0
- /package/dist/safe-bash/chunks/{zstd-R6RPHJYO.js.map → zstd-OG5RPYXO.js.map} +0 -0
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { commandRuntimeIdentity } from "@poe-platform/safe-bash/contracts/command";
|
|
2
|
+
import { FsError } from "@poe-platform/safe-bash/contracts/errors";
|
|
3
|
+
import { concatShellValues, shellValueBytes, shellValueFromBytes, shellValueText } from "@poe-platform/safe-bash/contracts/value";
|
|
4
|
+
const usage = "read: usage: read [-Eers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]\n";
|
|
5
|
+
function identifier(name) {
|
|
6
|
+
if (!name.length)
|
|
7
|
+
return false;
|
|
8
|
+
for (let index = 0; index < name.length; index++) {
|
|
9
|
+
const character = name[index];
|
|
10
|
+
if (character !== "_" && !(character >= "a" && character <= "z") && !(character >= "A" && character <= "Z") && !(index > 0 && character >= "0" && character <= "9"))
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
function decimal(value) {
|
|
16
|
+
let left = 0;
|
|
17
|
+
let right = value.length;
|
|
18
|
+
while (left < right && " \t\n\r\v\f".includes(value[left]))
|
|
19
|
+
left++;
|
|
20
|
+
while (right > left && " \t\n\r\v\f".includes(value[right - 1]))
|
|
21
|
+
right--;
|
|
22
|
+
const digits = value.slice(left, right);
|
|
23
|
+
let start = 0;
|
|
24
|
+
if (digits[0] === "+" || digits[0] === "-")
|
|
25
|
+
start++;
|
|
26
|
+
if (digits.length === start)
|
|
27
|
+
return undefined;
|
|
28
|
+
for (let index = start; index < digits.length; index++)
|
|
29
|
+
if (digits[index] < "0" || digits[index] > "9")
|
|
30
|
+
return undefined;
|
|
31
|
+
const number = Number(digits);
|
|
32
|
+
return Number.isInteger(number) && number >= 0 && number <= 2147483647 ? number : undefined;
|
|
33
|
+
}
|
|
34
|
+
function timeout(value) {
|
|
35
|
+
let offset = value.startsWith("+") || value.startsWith("-") ? 1 : 0;
|
|
36
|
+
let seconds = 0n;
|
|
37
|
+
while (offset < value.length && value[offset] !== ".") {
|
|
38
|
+
const character = value[offset++];
|
|
39
|
+
if (character < "0" || character > "9")
|
|
40
|
+
return undefined;
|
|
41
|
+
seconds = seconds * 10n + BigInt(character);
|
|
42
|
+
if (seconds > 9223372036854775807n)
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
if (value[offset] === ".")
|
|
46
|
+
offset++;
|
|
47
|
+
let fraction = 0;
|
|
48
|
+
let digits = 0;
|
|
49
|
+
while (offset < value.length && digits < 6) {
|
|
50
|
+
const character = value[offset++];
|
|
51
|
+
if (character < "0" || character > "9")
|
|
52
|
+
return undefined;
|
|
53
|
+
fraction = fraction * 10 + Number(character);
|
|
54
|
+
digits++;
|
|
55
|
+
}
|
|
56
|
+
fraction *= 10 ** (6 - digits);
|
|
57
|
+
if (digits === 6 && value[offset] !== undefined && value[offset] >= "5" && value[offset] <= "9")
|
|
58
|
+
fraction++;
|
|
59
|
+
if (value.startsWith("-") && (seconds > 0n || fraction > 0))
|
|
60
|
+
return undefined;
|
|
61
|
+
return Number(seconds & 4294967295n) * 1000 + fraction / 1000;
|
|
62
|
+
}
|
|
63
|
+
async function parse(context, validate) {
|
|
64
|
+
const options = { raw: false, exact: false, descriptor: 0, names: [] };
|
|
65
|
+
const args = context.argumentValues;
|
|
66
|
+
let offset = 0;
|
|
67
|
+
while (offset < args.length) {
|
|
68
|
+
const argument = args[offset];
|
|
69
|
+
const bytes = shellValueBytes(argument);
|
|
70
|
+
const text = shellValueText(argument);
|
|
71
|
+
if (text === "--") {
|
|
72
|
+
offset++;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
if (bytes[0] !== 45 || bytes.length === 1)
|
|
76
|
+
break;
|
|
77
|
+
offset++;
|
|
78
|
+
for (let index = 1; index < bytes.length; index++) {
|
|
79
|
+
const flag = String.fromCharCode(bytes[index]);
|
|
80
|
+
if (flag === "r") {
|
|
81
|
+
options.raw = true;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (flag === "e" || flag === "E" || flag === "s") {
|
|
85
|
+
options.terminal = flag;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (!"adnNptui".includes(flag)) {
|
|
89
|
+
await context.diagnostic(concatShellValues(["read: -", bytes[index] < 128 ? flag : shellValueFromBytes(bytes.subarray(index, index + 1)), ": invalid option"]));
|
|
90
|
+
await context.stderr.write(new TextEncoder().encode(usage));
|
|
91
|
+
return 2;
|
|
92
|
+
}
|
|
93
|
+
let value;
|
|
94
|
+
if (index + 1 < bytes.length)
|
|
95
|
+
value = typeof argument === "string" ? argument.slice(index + 1) : shellValueFromBytes(bytes.subarray(index + 1));
|
|
96
|
+
else if (offset < args.length)
|
|
97
|
+
value = args[offset++];
|
|
98
|
+
else {
|
|
99
|
+
await context.diagnostic(`read: -${flag}: option requires an argument`);
|
|
100
|
+
await context.stderr.write(new TextEncoder().encode(usage));
|
|
101
|
+
return 2;
|
|
102
|
+
}
|
|
103
|
+
const valueText = shellValueText(value);
|
|
104
|
+
if (flag === "a")
|
|
105
|
+
options.array = value;
|
|
106
|
+
else if (flag === "d")
|
|
107
|
+
options.delimiter = (index + 1 < bytes.length ? bytes[index + 1] : shellValueBytes(value)[0]) ?? 0;
|
|
108
|
+
else if (flag === "p" || flag === "i")
|
|
109
|
+
options.terminal = flag;
|
|
110
|
+
else if (flag === "t") {
|
|
111
|
+
const milliseconds = timeout(valueText);
|
|
112
|
+
if (milliseconds === undefined) {
|
|
113
|
+
await context.diagnostic(concatShellValues(["read: ", value, ": invalid timeout specification"]));
|
|
114
|
+
return 1;
|
|
115
|
+
}
|
|
116
|
+
options.timeout = milliseconds;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
const number = decimal(valueText);
|
|
120
|
+
if (number === undefined) {
|
|
121
|
+
const detail = flag === "u" ? "file descriptor specification" : `${valueText.startsWith("0x") || valueText.startsWith("0X") ? "hex " : ""}number`;
|
|
122
|
+
await context.diagnostic(concatShellValues(["read: ", value, `: invalid ${detail}`]));
|
|
123
|
+
return 1;
|
|
124
|
+
}
|
|
125
|
+
if (flag === "u") {
|
|
126
|
+
options.descriptor = number;
|
|
127
|
+
await validate(number);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
options.count = number;
|
|
131
|
+
if (flag === "N")
|
|
132
|
+
options.exact = true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
options.names = args.slice(offset);
|
|
139
|
+
return options;
|
|
140
|
+
}
|
|
141
|
+
async function execute(nonTerminalInput, context) {
|
|
142
|
+
const diagnosedDescriptorFailure = Symbol("diagnosed read descriptor failure");
|
|
143
|
+
const inputs = [];
|
|
144
|
+
let input;
|
|
145
|
+
let observer;
|
|
146
|
+
let record;
|
|
147
|
+
let writer;
|
|
148
|
+
const operation = {};
|
|
149
|
+
let completion;
|
|
150
|
+
let closed = false;
|
|
151
|
+
const check = () => { context.signal.throwIfAborted(); if (closed)
|
|
152
|
+
throw new Error("Read invocation is closed"); };
|
|
153
|
+
const close = () => {
|
|
154
|
+
closed = true;
|
|
155
|
+
return completion ??= (async () => {
|
|
156
|
+
await Promise.allSettled([operation.work]);
|
|
157
|
+
let failure;
|
|
158
|
+
for (const release of [() => writer?.close(), () => record?.release(), ...inputs.map(lease => () => lease.release()), () => observer?.release()]) {
|
|
159
|
+
try {
|
|
160
|
+
await release();
|
|
161
|
+
}
|
|
162
|
+
catch (reason) {
|
|
163
|
+
failure ??= { reason };
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (failure)
|
|
167
|
+
throw failure.reason;
|
|
168
|
+
})();
|
|
169
|
+
};
|
|
170
|
+
context.registerCleanup(close);
|
|
171
|
+
const validate = async (descriptor) => {
|
|
172
|
+
check();
|
|
173
|
+
try {
|
|
174
|
+
context.input.validateOpen(descriptor);
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
context.signal.throwIfAborted();
|
|
178
|
+
if (error instanceof FsError && error.code === "EBADF") {
|
|
179
|
+
await context.diagnostic(`read: ${descriptor}: invalid file descriptor: Bad file descriptor`);
|
|
180
|
+
throw diagnosedDescriptorFailure;
|
|
181
|
+
}
|
|
182
|
+
throw error;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
const select = (descriptor) => {
|
|
186
|
+
check();
|
|
187
|
+
try {
|
|
188
|
+
input = context.input.borrow(descriptor);
|
|
189
|
+
inputs.push(input);
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
context.signal.throwIfAborted();
|
|
193
|
+
if (!(error instanceof FsError && error.code === "EBADF"))
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
const observe = (descriptor) => {
|
|
198
|
+
check();
|
|
199
|
+
try {
|
|
200
|
+
observer = context.input.observe(descriptor);
|
|
201
|
+
}
|
|
202
|
+
catch (error) {
|
|
203
|
+
context.signal.throwIfAborted();
|
|
204
|
+
if (!(error instanceof FsError && error.code === "EBADF"))
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
const work = Promise.resolve().then(async () => {
|
|
209
|
+
check();
|
|
210
|
+
const options = await parse(context, validate);
|
|
211
|
+
check();
|
|
212
|
+
if (typeof options === "number")
|
|
213
|
+
return options;
|
|
214
|
+
if (options.timeout === 0) {
|
|
215
|
+
observe(options.descriptor);
|
|
216
|
+
check();
|
|
217
|
+
if (!observer)
|
|
218
|
+
return 1;
|
|
219
|
+
const { readiness } = await observer.probeRead();
|
|
220
|
+
check();
|
|
221
|
+
if (readiness === "ready")
|
|
222
|
+
return 0;
|
|
223
|
+
if (readiness === "blocked")
|
|
224
|
+
return 1;
|
|
225
|
+
if (readiness !== "unknown")
|
|
226
|
+
throw new TypeError("Invalid input readiness");
|
|
227
|
+
await context.diagnostic(observer.readable ? "read: input readiness is unknown for this cursor" : "read: descriptor readiness unavailable through this extension API");
|
|
228
|
+
return 1;
|
|
229
|
+
}
|
|
230
|
+
if (options.terminal !== undefined && !nonTerminalInput) {
|
|
231
|
+
await context.diagnostic(`read: -${options.terminal}: terminal input capabilities unavailable through this extension API`);
|
|
232
|
+
return 1;
|
|
233
|
+
}
|
|
234
|
+
const invalidName = async (name) => { await context.diagnostic(concatShellValues(["read: `", name, "': not a valid identifier"])); return 1; };
|
|
235
|
+
if (options.names[0] !== undefined && !identifier(shellValueText(options.names[0])))
|
|
236
|
+
return invalidName(options.names[0]);
|
|
237
|
+
if (options.array !== undefined && typeof context.bindings.openIndexed !== "function") {
|
|
238
|
+
await context.diagnostic("read: indexed writer unavailable through this extension API");
|
|
239
|
+
return 1;
|
|
240
|
+
}
|
|
241
|
+
const ifs = options.exact ? "" : context.bindings.get("IFS") ?? " \t\n";
|
|
242
|
+
select(options.descriptor);
|
|
243
|
+
check();
|
|
244
|
+
const inherited = options.timeout === undefined && options.count !== 0 ? context.bindings.get("TMOUT") : undefined;
|
|
245
|
+
const milliseconds = options.timeout ?? (inherited === undefined ? undefined : timeout(shellValueText(inherited)));
|
|
246
|
+
let timedOut = false;
|
|
247
|
+
if (!input && options.count !== 0) {
|
|
248
|
+
if (milliseconds !== undefined && milliseconds > 0) {
|
|
249
|
+
observe(options.descriptor);
|
|
250
|
+
check();
|
|
251
|
+
if (observer) {
|
|
252
|
+
const probe = await observer.probeRead();
|
|
253
|
+
check();
|
|
254
|
+
const readyUnreadable = observer.readable === false && probe.readiness === "ready";
|
|
255
|
+
if (probe.timeout !== "ignore" && !(readyUnreadable && probe.timeout === "unknown")) {
|
|
256
|
+
if (probe.readiness === "unknown" || probe.timeout !== "honor") {
|
|
257
|
+
await context.diagnostic("read: descriptor timeout observation unavailable through this extension API");
|
|
258
|
+
return 1;
|
|
259
|
+
}
|
|
260
|
+
if (probe.readiness === "blocked") {
|
|
261
|
+
const outcome = await observer.waitRead({ timeoutMs: milliseconds, signal: context.signal });
|
|
262
|
+
check();
|
|
263
|
+
if (outcome === "unknown") {
|
|
264
|
+
await context.diagnostic("read: descriptor timeout observation unavailable through this extension API");
|
|
265
|
+
return 1;
|
|
266
|
+
}
|
|
267
|
+
if (outcome !== "ready" && outcome !== "timeout")
|
|
268
|
+
throw new TypeError("Invalid descriptor wait result");
|
|
269
|
+
timedOut = outcome === "timeout";
|
|
270
|
+
}
|
|
271
|
+
else if (probe.readiness !== "ready")
|
|
272
|
+
throw new TypeError("Invalid descriptor readiness");
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (!timedOut) {
|
|
277
|
+
await context.diagnostic(`read: ${options.descriptor}: read error: Bad file descriptor`);
|
|
278
|
+
return 1;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
record = await input?.read(options.raw, {
|
|
282
|
+
...(options.count === undefined ? {} : { count: options.count }),
|
|
283
|
+
...(options.delimiter === undefined ? {} : { delimiter: options.delimiter }),
|
|
284
|
+
exact: options.exact,
|
|
285
|
+
...(options.count !== 0 && milliseconds !== undefined && milliseconds > 0 ? { timeoutMs: milliseconds } : {}),
|
|
286
|
+
});
|
|
287
|
+
check();
|
|
288
|
+
const status = timedOut || record?.reason === "timeout" ? 142 : record?.terminated ? 0 : 1;
|
|
289
|
+
if (options.array !== undefined) {
|
|
290
|
+
const name = shellValueText(options.array);
|
|
291
|
+
if (!identifier(name))
|
|
292
|
+
return invalidName(options.array);
|
|
293
|
+
if (context.bindings.describe(name).readonly) {
|
|
294
|
+
await context.diagnostic(`${name}: readonly variable`);
|
|
295
|
+
return 1;
|
|
296
|
+
}
|
|
297
|
+
writer = await context.bindings.openIndexed(name, { clear: true });
|
|
298
|
+
check();
|
|
299
|
+
const fields = await record?.fields(ifs) ?? [];
|
|
300
|
+
for (let index = 0; index < fields.length; index++) {
|
|
301
|
+
check();
|
|
302
|
+
await writer.set(index, fields[index].value);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
const names = options.names.length ? options.names : ["REPLY"];
|
|
307
|
+
const fields = options.names.length ? await record?.fields(ifs, names.length) ?? [] : undefined;
|
|
308
|
+
for (let index = 0; index < names.length; index++) {
|
|
309
|
+
check();
|
|
310
|
+
const original = names[index];
|
|
311
|
+
const name = shellValueText(original);
|
|
312
|
+
if (!identifier(name))
|
|
313
|
+
return invalidName(original);
|
|
314
|
+
if (context.bindings.describe(name).readonly) {
|
|
315
|
+
await context.diagnostic(`${name}: readonly variable`);
|
|
316
|
+
return options.names.length === 0 || index < names.length - 1 ? 2 : 1;
|
|
317
|
+
}
|
|
318
|
+
await context.bindings.assign(name, fields ? fields[index]?.value ?? "" : record?.shellValue ?? "");
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return status;
|
|
322
|
+
});
|
|
323
|
+
operation.work = work;
|
|
324
|
+
let result = 1;
|
|
325
|
+
let failure;
|
|
326
|
+
try {
|
|
327
|
+
result = await work;
|
|
328
|
+
}
|
|
329
|
+
catch (reason) {
|
|
330
|
+
if (reason === diagnosedDescriptorFailure)
|
|
331
|
+
result = 1;
|
|
332
|
+
else
|
|
333
|
+
failure = { reason };
|
|
334
|
+
}
|
|
335
|
+
try {
|
|
336
|
+
await close();
|
|
337
|
+
}
|
|
338
|
+
catch (reason) {
|
|
339
|
+
failure ??= { reason };
|
|
340
|
+
}
|
|
341
|
+
context.signal.throwIfAborted();
|
|
342
|
+
if (failure)
|
|
343
|
+
throw failure.reason;
|
|
344
|
+
return result;
|
|
345
|
+
}
|
|
346
|
+
export function readExtension(options = {}) {
|
|
347
|
+
const nonTerminalInput = options.nonTerminalInput === true;
|
|
348
|
+
return { name: "extended-read", runtimeIdentity: commandRuntimeIdentity, create: () => ({
|
|
349
|
+
builtins: [{ name: "read", replace: true, execute: execute.bind(undefined, nonTerminalInput) }],
|
|
350
|
+
}) };
|
|
351
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ShellExtension } from "@poe-platform/safe-bash/optional-host";
|
|
2
|
+
export interface TrapSignalHost {
|
|
3
|
+
subscribe(deliver: (signal: string | number) => boolean, scope: object): () => void | Promise<void>;
|
|
4
|
+
}
|
|
5
|
+
export interface TrapExtensionOptions {
|
|
6
|
+
readonly signalNames?: Readonly<Record<string, number>>;
|
|
7
|
+
readonly signalHost?: TrapSignalHost;
|
|
8
|
+
}
|
|
9
|
+
export declare function trapExtension(configuration?: TrapExtensionOptions): ShellExtension;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { constants, platform } from "node:os";
|
|
2
|
+
import { shellValueByteLength, shellValueBytes, shellValueText } from "@poe-platform/safe-bash/contracts/value";
|
|
3
|
+
import { commandRuntimeIdentity } from "@poe-platform/safe-bash/contracts/command";
|
|
4
|
+
function quote(source) {
|
|
5
|
+
const bytes = shellValueBytes(source);
|
|
6
|
+
const parts = [Buffer.from("'")];
|
|
7
|
+
let start = 0;
|
|
8
|
+
for (let index = 0; index < bytes.length; index++)
|
|
9
|
+
if (bytes[index] === 39) {
|
|
10
|
+
parts.push(bytes.subarray(start, index), Buffer.from("'\\''"));
|
|
11
|
+
start = index + 1;
|
|
12
|
+
}
|
|
13
|
+
parts.push(bytes.subarray(start), Buffer.from("'"));
|
|
14
|
+
return Buffer.concat(parts);
|
|
15
|
+
}
|
|
16
|
+
export function trapExtension(configuration = {}) {
|
|
17
|
+
const catalog = { ...(configuration.signalNames ?? { ...constants.signals, ...(platform() === "darwin" ? { SIGEMT: 7 } : {}) }) };
|
|
18
|
+
const names = new Map([[0, "EXIT"]]);
|
|
19
|
+
const aliases = new Map([["EXIT", 0], ["SIGEXIT", 0]]);
|
|
20
|
+
for (const [name, number] of Object.entries(catalog)) {
|
|
21
|
+
if (!name.startsWith("SIG") || !Number.isSafeInteger(number) || number <= 0 || number > 1024)
|
|
22
|
+
throw new TypeError("Invalid trap signal catalog");
|
|
23
|
+
if (!names.has(number))
|
|
24
|
+
names.set(number, name);
|
|
25
|
+
aliases.set(name, number);
|
|
26
|
+
aliases.set(name.slice(3), number);
|
|
27
|
+
}
|
|
28
|
+
const pseudoBase = Math.max(...names.keys()) + 1;
|
|
29
|
+
for (const [index, name] of ["DEBUG", "ERR", "RETURN"].entries()) {
|
|
30
|
+
names.set(pseudoBase + index, name);
|
|
31
|
+
aliases.set(name, pseudoBase + index);
|
|
32
|
+
aliases.set("SIG" + name, pseudoBase + index);
|
|
33
|
+
}
|
|
34
|
+
const resolve = (value) => {
|
|
35
|
+
const text = String(value).toUpperCase();
|
|
36
|
+
const named = aliases.get(text);
|
|
37
|
+
if (named !== undefined)
|
|
38
|
+
return named;
|
|
39
|
+
const digits = text[0] === "+" ? text.slice(1) : text;
|
|
40
|
+
if (!digits || [...digits].some(character => character < "0" || character > "9"))
|
|
41
|
+
return undefined;
|
|
42
|
+
const number = Number(digits);
|
|
43
|
+
return names.has(number) ? number : undefined;
|
|
44
|
+
};
|
|
45
|
+
function instance(actions = new Map(), errorTrace = false, functionTrace = false, inheritedIgnored = new Set(), extendedDebug = false) {
|
|
46
|
+
const options = [{ name: "errtrace", flag: "E", enabled: errorTrace }, { name: "functrace", flag: "T", enabled: functionTrace }];
|
|
47
|
+
const running = new Set();
|
|
48
|
+
const pending = new Set();
|
|
49
|
+
const functions = [];
|
|
50
|
+
const sources = [];
|
|
51
|
+
const run = async (number, context) => {
|
|
52
|
+
context.signal.throwIfAborted();
|
|
53
|
+
const action = actions.get(number);
|
|
54
|
+
if (!action?.active || !shellValueByteLength(action.source) || running.has(number))
|
|
55
|
+
return;
|
|
56
|
+
running.add(number);
|
|
57
|
+
try {
|
|
58
|
+
return await context.evaluate(action.source, { name: number === 0 ? "exit trap" : "trap" });
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
running.delete(number);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
options,
|
|
66
|
+
shoptOptions: [{ name: "extdebug", get enabled() { return extendedDebug; }, set enabled(value) { extendedDebug = value; for (const option of options)
|
|
67
|
+
option.enabled = value; } }],
|
|
68
|
+
start(context) {
|
|
69
|
+
if (!configuration.signalHost)
|
|
70
|
+
return;
|
|
71
|
+
let open = true;
|
|
72
|
+
const subscription = {};
|
|
73
|
+
context.registerCleanup(async () => { open = false; pending.clear(); await subscription.close?.(); });
|
|
74
|
+
subscription.close = configuration.signalHost.subscribe(signal => {
|
|
75
|
+
if (!open || context.signal.aborted)
|
|
76
|
+
return false;
|
|
77
|
+
const number = resolve(signal);
|
|
78
|
+
if (number === undefined || number === 0 || number >= pseudoBase || names.get(number) === "SIGKILL" || names.get(number) === "SIGSTOP")
|
|
79
|
+
return false;
|
|
80
|
+
const action = actions.get(number);
|
|
81
|
+
if (!action?.active)
|
|
82
|
+
return false;
|
|
83
|
+
if (shellValueByteLength(action.source)) {
|
|
84
|
+
pending.add(number);
|
|
85
|
+
context.interruptWait?.((128 + number) % 256);
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
}, context.scope);
|
|
89
|
+
},
|
|
90
|
+
builtins: [{
|
|
91
|
+
name: "trap", special: true,
|
|
92
|
+
async execute(context) {
|
|
93
|
+
context.signal.throwIfAborted();
|
|
94
|
+
const args = [...context.args];
|
|
95
|
+
let print = false, list = false;
|
|
96
|
+
while (args[0]?.startsWith("-") && args[0] !== "-") {
|
|
97
|
+
const option = args.shift();
|
|
98
|
+
if (option === "--")
|
|
99
|
+
break;
|
|
100
|
+
for (const flag of option.slice(1)) {
|
|
101
|
+
if (flag === "p")
|
|
102
|
+
print = true;
|
|
103
|
+
else if (flag === "l")
|
|
104
|
+
list = true;
|
|
105
|
+
else {
|
|
106
|
+
await context.stderr.write(new TextEncoder().encode(`trap: -${flag}: invalid option\ntrap: usage: trap [-lp] [arg signal_spec ...]\n`));
|
|
107
|
+
return 2;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (list) {
|
|
112
|
+
const signals = [...names].filter(([number]) => number > 0 && number < pseudoBase).sort(([left], [right]) => left - right);
|
|
113
|
+
let output = "";
|
|
114
|
+
for (const [index, [number, name]] of signals.entries())
|
|
115
|
+
output += `${String(number).padStart(2, " ")}) ${name}${index % 4 === 3 ? "\n" : "\t"}`;
|
|
116
|
+
if (!output.endsWith("\n"))
|
|
117
|
+
output += "\n";
|
|
118
|
+
await context.stdout.write(new TextEncoder().encode(output));
|
|
119
|
+
return 0;
|
|
120
|
+
}
|
|
121
|
+
if (!args.length)
|
|
122
|
+
print = true;
|
|
123
|
+
let action;
|
|
124
|
+
const first = args[0];
|
|
125
|
+
const numericReset = !!first && [...first].every(character => character >= "0" && character <= "9");
|
|
126
|
+
if (!print && args.length > 1 && !numericReset) {
|
|
127
|
+
action = context.argumentValues[context.args.length - args.length];
|
|
128
|
+
args.shift();
|
|
129
|
+
}
|
|
130
|
+
if (!print && args.length === 1 && args[0] === "-") {
|
|
131
|
+
await context.stderr.write(new TextEncoder().encode("trap: usage: trap [-lp] [arg signal_spec ...]\n"));
|
|
132
|
+
return 2;
|
|
133
|
+
}
|
|
134
|
+
if (action !== undefined && shellValueText(action) !== "-")
|
|
135
|
+
context.accountSource(action);
|
|
136
|
+
const targets = args.length ? args : [...actions.keys()].sort((left, right) => left - right).map(String);
|
|
137
|
+
let status = 0;
|
|
138
|
+
for (const target of targets) {
|
|
139
|
+
const number = resolve(target);
|
|
140
|
+
if (number === undefined) {
|
|
141
|
+
await context.diagnostic(`trap: ${target}: invalid signal specification`);
|
|
142
|
+
status = 1;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (print) {
|
|
146
|
+
const current = actions.get(number);
|
|
147
|
+
if (current)
|
|
148
|
+
await context.stdout.write(Buffer.concat([Buffer.from("trap -- "), quote(current.source), Buffer.from(` ${names.get(number)}\n`)]));
|
|
149
|
+
}
|
|
150
|
+
else if (inheritedIgnored.has(number))
|
|
151
|
+
continue;
|
|
152
|
+
else if (action === undefined || shellValueText(action) === "-")
|
|
153
|
+
actions.delete(number);
|
|
154
|
+
else
|
|
155
|
+
actions.set(number, { source: action, active: true });
|
|
156
|
+
}
|
|
157
|
+
return status;
|
|
158
|
+
},
|
|
159
|
+
}],
|
|
160
|
+
fork(scope) {
|
|
161
|
+
const inherited = new Map();
|
|
162
|
+
for (const [number, action] of actions) {
|
|
163
|
+
if (scope === "process") {
|
|
164
|
+
if (number > 0 && number < pseudoBase && !shellValueByteLength(action.source))
|
|
165
|
+
inherited.set(number, action);
|
|
166
|
+
}
|
|
167
|
+
else
|
|
168
|
+
inherited.set(number, { source: action.source, active: !shellValueByteLength(action.source) || names.get(number) === "ERR" && options[0].enabled || ["DEBUG", "RETURN"].includes(names.get(number)) && options[1].enabled });
|
|
169
|
+
}
|
|
170
|
+
return instance(inherited, scope !== "process" && options[0].enabled, scope !== "process" && options[1].enabled, scope === "process" ? new Set(inherited.keys()) : inheritedIgnored, scope !== "process" && extendedDebug);
|
|
171
|
+
},
|
|
172
|
+
async event(event, context) {
|
|
173
|
+
if (event === "function-enter") {
|
|
174
|
+
functions.push(new Map(actions));
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (event === "function-leave") {
|
|
178
|
+
functions.pop();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (event === "source-enter") {
|
|
182
|
+
sources.push(actions.get(aliases.get("DEBUG")));
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (event === "source-leave") {
|
|
186
|
+
const previous = sources.pop();
|
|
187
|
+
if (previous && !actions.has(aliases.get("DEBUG")))
|
|
188
|
+
actions.set(aliases.get("DEBUG"), previous);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
for (const number of pending) {
|
|
192
|
+
if (running.has(number))
|
|
193
|
+
continue;
|
|
194
|
+
pending.delete(number);
|
|
195
|
+
await run(number, context);
|
|
196
|
+
}
|
|
197
|
+
const name = event === "exit" ? "EXIT" : event === "error" ? "ERR" : event === "command" ? "DEBUG" : "RETURN";
|
|
198
|
+
if (name === "DEBUG" && context.sourceDepth > 0 && sources.at(-1) === actions.get(aliases.get(name)) && !options[1].enabled)
|
|
199
|
+
return;
|
|
200
|
+
const inherited = functions.at(-1)?.get(aliases.get(name)) === actions.get(aliases.get(name));
|
|
201
|
+
if (context.functionDepth > 0 && inherited && (name === "ERR" && !options[0].enabled || (name === "DEBUG" || name === "RETURN") && !options[1].enabled))
|
|
202
|
+
return;
|
|
203
|
+
const status = await run(aliases.get(name), context);
|
|
204
|
+
if (name === "DEBUG" && extendedDebug && status)
|
|
205
|
+
return status === 2 && (context.functionDepth > 0 || context.sourceDepth > 0) ? { action: "return", status } : { action: "skip" };
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
return { name: "trap", runtimeIdentity: commandRuntimeIdentity, create: () => instance() };
|
|
210
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { codeOf, output, pathOf } from "./commands/internal.js";
|
|
2
|
+
export { compareCopyIdentity, compareObservedEntries } from "./commands/copy-identity.js";
|
|
3
|
+
export type { PreparedShellChild, ShellBindingReference, ShellBindingResult, ShellChildPreparation, ShellExecutionCheckpoint, ShellExtension, ShellExtensionBuiltin, ShellExtensionContext, ShellExtensionEvent, ShellExtensionInstance, ShellExtensionOption, ShellExtensionScope, ShellIndexedWriter, ShellInputBorrow, ShellInputObserver, ShellListTerminatorContext, ShellListTerminatorHook, ShellSpecialParameterHook, } from "./shell/extensions.js";
|
|
4
|
+
export type { RawRecord, ReadLine } from "./shell/input.js";
|
|
5
|
+
//# sourceMappingURL=optional-host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optional-host.d.ts","sourceRoot":"","sources":["../src/optional-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1F,YAAY,EACV,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,wBAAwB,EACxB,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optional-host.js","sourceRoot":"","sources":["../src/optional-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Admission, ArrayOwner } from "./ledger.js";
|
|
2
2
|
import type { Tickets } from "./ledger.js";
|
|
3
|
-
import {
|
|
3
|
+
import type { ShellValue } from "../../contracts/value.js";
|
|
4
4
|
export declare const controlNames: ReadonlySet<string>;
|
|
5
5
|
export declare class OwnedText {
|
|
6
|
-
readonly
|
|
6
|
+
readonly shellValue: ShellValue;
|
|
7
7
|
readonly bytes: number;
|
|
8
8
|
readonly admission: Admission;
|
|
9
|
-
readonly rawValue?: ShellValue | undefined;
|
|
10
9
|
references: number;
|
|
11
|
-
constructor(
|
|
10
|
+
constructor(shellValue: ShellValue, bytes: number, admission: Admission);
|
|
11
|
+
get value(): string;
|
|
12
12
|
retain(): this;
|
|
13
13
|
release(): void;
|
|
14
14
|
}
|
|
15
|
-
export declare function textToken(owner: ArrayOwner, value:
|
|
15
|
+
export declare function textToken(owner: ArrayOwner, value: ShellValue, signal: AbortSignal): Promise<OwnedText>;
|
|
16
16
|
export declare function valueToken(owner: ArrayOwner, value: ShellValue, signal: AbortSignal): Promise<OwnedText>;
|
|
17
17
|
export interface Element {
|
|
18
18
|
readonly text: OwnedText;
|
|
@@ -39,6 +39,7 @@ export declare class IndexedBinding {
|
|
|
39
39
|
keyIndex(value: ShellValue, owner: ArrayOwner, signal: AbortSignal, create?: boolean): Promise<number | undefined>;
|
|
40
40
|
remove(index: number): void;
|
|
41
41
|
get(index: number): string | undefined;
|
|
42
|
+
getValue(index: number): ShellValue | undefined;
|
|
42
43
|
retain(): this;
|
|
43
44
|
release(): Promise<void> | undefined;
|
|
44
45
|
insert(index: number, text: OwnedText): void;
|
|
@@ -71,6 +72,13 @@ interface NamedBinding {
|
|
|
71
72
|
readonly name: OwnedText;
|
|
72
73
|
readonly admission: Admission;
|
|
73
74
|
}
|
|
75
|
+
export interface PreparedBinding {
|
|
76
|
+
readonly binding: IndexedBinding;
|
|
77
|
+
readonly tickets: Tickets;
|
|
78
|
+
validate(): void;
|
|
79
|
+
publish(): Promise<void> | undefined;
|
|
80
|
+
close(): Promise<void>;
|
|
81
|
+
}
|
|
74
82
|
export declare class BindingStore {
|
|
75
83
|
owner: ArrayOwner;
|
|
76
84
|
readonly bindings: Map<string, NamedBinding>;
|
|
@@ -79,6 +87,7 @@ export declare class BindingStore {
|
|
|
79
87
|
private constructor();
|
|
80
88
|
static create(parent: ArrayOwner): BindingStore;
|
|
81
89
|
get(name: string): IndexedBinding | undefined;
|
|
90
|
+
prepare(name: string, signal: AbortSignal, copy?: boolean): Promise<PreparedBinding>;
|
|
82
91
|
watch(name: string, operation: ArrayOwner, signal: AbortSignal, owner?: ArrayOwner): Promise<BindingWatch>;
|
|
83
92
|
retire(name: string, watch: Watch): void;
|
|
84
93
|
tickets(name?: string): Admission;
|
|
@@ -91,6 +100,7 @@ export declare class BindingStore {
|
|
|
91
100
|
readonly name: OwnedText;
|
|
92
101
|
readonly admission: Admission;
|
|
93
102
|
}, restoring?: boolean, owner?: ArrayOwner): Promise<void> | undefined;
|
|
103
|
+
revise(name: string, binding: IndexedBinding, tickets: Tickets): void;
|
|
94
104
|
remove(name: string, tickets: Tickets): Promise<void> | undefined;
|
|
95
105
|
}
|
|
96
106
|
export {};
|