@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,71 @@
|
|
|
1
|
+
import { InstallError, quote } from "./options.js";
|
|
2
|
+
export function parseMode(text, rawBytes) {
|
|
3
|
+
if (text === undefined)
|
|
4
|
+
return { file: 0o755, directory: 0o755, directoryMask: 0o7777 };
|
|
5
|
+
const invalid = () => new InstallError(`invalid mode ${quote(text, true, rawBytes)}`);
|
|
6
|
+
const numeric = "+-=".includes(text[0] ?? "!") ? text.slice(1) : text;
|
|
7
|
+
if (numeric && Array.from(numeric).every(character => character >= "0" && character <= "7")) {
|
|
8
|
+
const bits = Number.parseInt(numeric, 8);
|
|
9
|
+
if (bits > 0o7777 || !Number.isSafeInteger(bits))
|
|
10
|
+
throw invalid();
|
|
11
|
+
const subtract = text[0] === "-";
|
|
12
|
+
return { file: subtract ? 0 : bits, directory: subtract ? 0 : bits, directoryMask: text[0] === "+" || subtract ? bits : 0o7777 };
|
|
13
|
+
}
|
|
14
|
+
let file = 0, directory = 0, directoryMask = 0;
|
|
15
|
+
for (const clause of text.split(",")) {
|
|
16
|
+
let offset = 0, who = "";
|
|
17
|
+
while (offset < clause.length && "ugoa".includes(clause[offset]))
|
|
18
|
+
who += clause[offset++];
|
|
19
|
+
const all = !who || who.includes("a");
|
|
20
|
+
const users = (all || who.includes("u") ? 0o4700 : 0) | (all || who.includes("g") ? 0o2070 : 0) | (all || who.includes("o") ? 0o1007 : 0);
|
|
21
|
+
if (offset === clause.length)
|
|
22
|
+
throw invalid();
|
|
23
|
+
while (offset < clause.length) {
|
|
24
|
+
const operator = clause[offset++];
|
|
25
|
+
if (!"+-=".includes(operator))
|
|
26
|
+
throw invalid();
|
|
27
|
+
let permissions = "";
|
|
28
|
+
while (offset < clause.length && !"+-=".includes(clause[offset]))
|
|
29
|
+
permissions += clause[offset++];
|
|
30
|
+
const copy = permissions.length === 1 && "ugo".includes(permissions);
|
|
31
|
+
if (!copy && !Array.from(permissions).every(character => "rwxXst".includes(character)))
|
|
32
|
+
throw invalid();
|
|
33
|
+
const bitsFor = (current, isDirectory) => {
|
|
34
|
+
let bits = 0;
|
|
35
|
+
if (copy) {
|
|
36
|
+
const shift = permissions === "u" ? 6 : permissions === "g" ? 3 : 0;
|
|
37
|
+
const value = current >> shift & 7;
|
|
38
|
+
bits = value << 6 | value << 3 | value;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
if (permissions.includes("r"))
|
|
42
|
+
bits |= 0o444;
|
|
43
|
+
if (permissions.includes("w"))
|
|
44
|
+
bits |= 0o222;
|
|
45
|
+
if (permissions.includes("x") || permissions.includes("X") && (isDirectory || (current & 0o111) !== 0))
|
|
46
|
+
bits |= 0o111;
|
|
47
|
+
if (permissions.includes("s"))
|
|
48
|
+
bits |= 0o6000;
|
|
49
|
+
if (permissions.includes("t"))
|
|
50
|
+
bits |= 0o1000;
|
|
51
|
+
}
|
|
52
|
+
return bits & users;
|
|
53
|
+
};
|
|
54
|
+
const fileBits = bitsFor(file, false), directoryBits = bitsFor(directory, true);
|
|
55
|
+
if (operator === "+") {
|
|
56
|
+
file |= fileBits;
|
|
57
|
+
directory |= directoryBits;
|
|
58
|
+
}
|
|
59
|
+
else if (operator === "-") {
|
|
60
|
+
file &= ~fileBits;
|
|
61
|
+
directory &= ~directoryBits;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
file = file & ~users | fileBits;
|
|
65
|
+
directory = directory & ~users | directoryBits;
|
|
66
|
+
}
|
|
67
|
+
directoryMask |= operator === "=" ? users : directoryBits;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return { file, directory, directoryMask };
|
|
71
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { CommandContext } from "@poe-platform/safe-bash/contracts/index";
|
|
2
|
+
export interface InstallContextRequest {
|
|
3
|
+
readonly path: string;
|
|
4
|
+
readonly source?: string;
|
|
5
|
+
readonly label?: string;
|
|
6
|
+
readonly mode: "default" | "preserve" | "explicit";
|
|
7
|
+
}
|
|
8
|
+
export interface InstallModeRequest {
|
|
9
|
+
readonly path: string;
|
|
10
|
+
readonly mode: number;
|
|
11
|
+
readonly kind: "file" | "new-directory" | "existing-directory";
|
|
12
|
+
}
|
|
13
|
+
export interface InstallCommandsOptions {
|
|
14
|
+
readonly replace?: boolean;
|
|
15
|
+
readonly identity?: {
|
|
16
|
+
readonly uid: number;
|
|
17
|
+
readonly gid: number;
|
|
18
|
+
};
|
|
19
|
+
readonly resolveUser?: (name: string, context: CommandContext) => number | undefined | Promise<number | undefined>;
|
|
20
|
+
readonly resolveGroup?: (name: string, context: CommandContext) => number | undefined | Promise<number | undefined>;
|
|
21
|
+
readonly chown?: (path: string, uid: number | undefined, gid: number | undefined, context: CommandContext) => void | Promise<void>;
|
|
22
|
+
readonly setMode?: (request: InstallModeRequest, context: CommandContext) => void | Promise<void>;
|
|
23
|
+
readonly strip?: (path: string, program: string, context: CommandContext) => number | Promise<number>;
|
|
24
|
+
readonly renameExclusive?: (source: string, destination: string, context: CommandContext) => void | Promise<void>;
|
|
25
|
+
readonly maxFileBytes?: number;
|
|
26
|
+
readonly securityContext?: {
|
|
27
|
+
readonly enabled: boolean;
|
|
28
|
+
readonly apply?: (request: InstallContextRequest, context: CommandContext) => void | Promise<void>;
|
|
29
|
+
readonly matches?: (source: string, destination: string, context: CommandContext) => boolean | Promise<boolean>;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export declare class InstallError extends Error {
|
|
33
|
+
readonly usage: boolean;
|
|
34
|
+
constructor(message: string, usage?: boolean);
|
|
35
|
+
}
|
|
36
|
+
export declare function quote(value: string, numeric?: boolean, rawBytes?: Uint8Array): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export class InstallError extends Error {
|
|
2
|
+
usage;
|
|
3
|
+
constructor(message, usage = false) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.usage = usage;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export function quote(value, numeric = false, rawBytes) {
|
|
9
|
+
const escapes = new Map([[7, "a"], [8, "b"], [9, "t"], [10, "n"], [11, "v"], [12, "f"], [13, "r"]]);
|
|
10
|
+
const bytes = rawBytes ?? new TextEncoder().encode(value);
|
|
11
|
+
if (!numeric && bytes.every(byte => byte >= 32 && byte < 127)) {
|
|
12
|
+
return value.includes("'") && !["\"", "$", "`", "\\"].some(character => value.includes(character))
|
|
13
|
+
? `"${value}"` : `'${value.replaceAll("'", "'\\''")}'`;
|
|
14
|
+
}
|
|
15
|
+
let result = "'", escaped = false;
|
|
16
|
+
for (const byte of bytes) {
|
|
17
|
+
const special = byte < 32 || byte >= 127;
|
|
18
|
+
if (!numeric && special !== escaped) {
|
|
19
|
+
result += special ? "'$'" : "''";
|
|
20
|
+
escaped = special;
|
|
21
|
+
}
|
|
22
|
+
result += special ? `\\${escapes.get(byte) ?? byte.toString(8).padStart(3, "0")}`
|
|
23
|
+
: numeric && (byte === 39 || byte === 92) ? `\\${String.fromCharCode(byte)}`
|
|
24
|
+
: byte === 39 ? "'\\''" : String.fromCharCode(byte);
|
|
25
|
+
}
|
|
26
|
+
return `${result}'`;
|
|
27
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { getCommandArguments } from "@poe-platform/safe-bash/contracts/index";
|
|
2
|
+
export const wordMax = (1n << 64n) - 1n;
|
|
3
|
+
export const countMax = (1n << 63n) - 1n;
|
|
4
|
+
export class Diagnostic extends Error {
|
|
5
|
+
bytes;
|
|
6
|
+
constructor(message, bytes) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.bytes = bytes;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function quote(value) {
|
|
12
|
+
let result = "'";
|
|
13
|
+
const escapes = { "\n": "\\n", "\r": "\\r", "\t": "\\t", "\b": "\\b", "\f": "\\f", "\v": "\\v", "\u0007": "\\a", "\\": "\\\\", "'": "\\'" };
|
|
14
|
+
for (const code of typeof value === "string" ? Buffer.from(value) : value) {
|
|
15
|
+
const character = String.fromCharCode(code);
|
|
16
|
+
result += escapes[character] ?? (code < 32 || code >= 127 ? `\\${code.toString(8).padStart(3, "0")}` : character);
|
|
17
|
+
}
|
|
18
|
+
return `${result}'`;
|
|
19
|
+
}
|
|
20
|
+
export function fileQuote(value) {
|
|
21
|
+
if (value && value !== "{" && value !== "}" && !"#~".includes(value[0]) && Array.from(value).every(character => "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_+-./,%#@]{}~".includes(character)))
|
|
22
|
+
return value;
|
|
23
|
+
if (!value.includes("'") && !Array.from(value).some(character => character.charCodeAt(0) < 32 || character.charCodeAt(0) >= 127))
|
|
24
|
+
return `'${value}'`;
|
|
25
|
+
if (value.includes("'") && !Array.from(value).some(character => "\"\\$`".includes(character) || character.charCodeAt(0) < 32 || character.charCodeAt(0) >= 127))
|
|
26
|
+
return `"${value}"`;
|
|
27
|
+
let result = "'";
|
|
28
|
+
let escaped = false;
|
|
29
|
+
for (const code of Buffer.from(value)) {
|
|
30
|
+
const character = String.fromCharCode(code);
|
|
31
|
+
const control = code < 32 || code >= 127;
|
|
32
|
+
if (control !== escaped) {
|
|
33
|
+
result += control ? "'$'" : "''";
|
|
34
|
+
escaped = control;
|
|
35
|
+
}
|
|
36
|
+
result += control ? code >= 127 ? `\\${code.toString(8).padStart(3, "0")}` : quote(character).slice(1, -1) : character === "'" ? "'\\''" : character;
|
|
37
|
+
}
|
|
38
|
+
return `${result}'`;
|
|
39
|
+
}
|
|
40
|
+
function usage(message) {
|
|
41
|
+
throw new Diagnostic(`shuf: ${message}\nTry 'shuf --help' for more information.\n`);
|
|
42
|
+
}
|
|
43
|
+
function unsigned(value, start = 0) {
|
|
44
|
+
let cursor = start;
|
|
45
|
+
while (cursor < value.length && " \t\n\r\v\f".includes(value[cursor]))
|
|
46
|
+
cursor++;
|
|
47
|
+
if (value[cursor] === "+")
|
|
48
|
+
cursor++;
|
|
49
|
+
const first = cursor;
|
|
50
|
+
let number = 0n;
|
|
51
|
+
while (cursor < value.length && value[cursor] >= "0" && value[cursor] <= "9") {
|
|
52
|
+
if (number <= wordMax)
|
|
53
|
+
number = number * 10n + BigInt(value[cursor]);
|
|
54
|
+
cursor++;
|
|
55
|
+
}
|
|
56
|
+
return { number, cursor, valid: cursor > first, overflow: number > wordMax };
|
|
57
|
+
}
|
|
58
|
+
const longOptions = ["echo", "input-range", "head-count", "output", "random-source", "repeat", "zero-terminated", "help", "version"];
|
|
59
|
+
export function parse(context) {
|
|
60
|
+
const result = {
|
|
61
|
+
echo: false, repeat: false, delimiter: 10, count: countMax,
|
|
62
|
+
range: undefined,
|
|
63
|
+
output: undefined, random: undefined,
|
|
64
|
+
action: undefined, operands: [],
|
|
65
|
+
};
|
|
66
|
+
const apply = (option, value, valueIndex, valueOffset) => {
|
|
67
|
+
switch (option) {
|
|
68
|
+
case "e":
|
|
69
|
+
result.echo = true;
|
|
70
|
+
break;
|
|
71
|
+
case "r":
|
|
72
|
+
result.repeat = true;
|
|
73
|
+
break;
|
|
74
|
+
case "z":
|
|
75
|
+
result.delimiter = 0;
|
|
76
|
+
break;
|
|
77
|
+
case "i": {
|
|
78
|
+
if (result.range)
|
|
79
|
+
throw new Diagnostic("shuf: multiple -i options specified\n");
|
|
80
|
+
const low = unsigned(value);
|
|
81
|
+
const high = unsigned(value, low.cursor + 1);
|
|
82
|
+
const overflow = low.overflow || low.valid && value[low.cursor] === "-" && high.overflow && high.cursor === value.length;
|
|
83
|
+
const size = high.number - low.number + 1n;
|
|
84
|
+
if (!low.valid || !high.valid || value[low.cursor] !== "-" || high.cursor !== value.length || overflow || size < 0n || size > wordMax) {
|
|
85
|
+
throw new Diagnostic(`shuf: invalid input range: ${quote(value)}${overflow ? ": Value too large to be stored in data type" : ""}\n`);
|
|
86
|
+
}
|
|
87
|
+
result.range = { low: low.number, size };
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
case "n": {
|
|
91
|
+
const parsed = unsigned(value);
|
|
92
|
+
if (!parsed.valid || parsed.cursor !== value.length) {
|
|
93
|
+
throw new Diagnostic(`shuf: invalid line count: ${quote(getCommandArguments(context).bytes(valueIndex).subarray(valueOffset))}\n`);
|
|
94
|
+
}
|
|
95
|
+
if (!parsed.overflow && parsed.number < result.count)
|
|
96
|
+
result.count = parsed.number;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
case "o":
|
|
100
|
+
if (result.output !== undefined && result.output !== value)
|
|
101
|
+
throw new Diagnostic("shuf: multiple output files specified\n");
|
|
102
|
+
result.output = value;
|
|
103
|
+
break;
|
|
104
|
+
case "random-source":
|
|
105
|
+
if (result.random !== undefined && result.random !== value)
|
|
106
|
+
throw new Diagnostic("shuf: multiple random sources specified\n");
|
|
107
|
+
result.random = value;
|
|
108
|
+
break;
|
|
109
|
+
case "help":
|
|
110
|
+
case "version":
|
|
111
|
+
result.action = option;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
let ended = false;
|
|
116
|
+
for (let index = 0; index < context.args.length; index++) {
|
|
117
|
+
context.signal.throwIfAborted();
|
|
118
|
+
const argument = context.args[index];
|
|
119
|
+
if (ended || argument === "-" || !argument.startsWith("-")) {
|
|
120
|
+
result.operands.push(index);
|
|
121
|
+
if (Object.hasOwn(context.env, "POSIXLY_CORRECT"))
|
|
122
|
+
ended = true;
|
|
123
|
+
}
|
|
124
|
+
else if (argument === "--")
|
|
125
|
+
ended = true;
|
|
126
|
+
else if (argument.startsWith("--")) {
|
|
127
|
+
const equal = argument.indexOf("=");
|
|
128
|
+
const name = argument.slice(2, equal < 0 ? undefined : equal);
|
|
129
|
+
const matches = longOptions.includes(name) ? [name] : longOptions.filter(option => option.startsWith(name));
|
|
130
|
+
if (!matches.length)
|
|
131
|
+
usage(`unrecognized option '${argument}'`);
|
|
132
|
+
if (matches.length > 1)
|
|
133
|
+
usage(`option '${argument}' is ambiguous; possibilities:${matches.map(option => ` '--${option}'`).join("")}`);
|
|
134
|
+
const option = matches[0];
|
|
135
|
+
const required = ["input-range", "head-count", "output", "random-source"].includes(option);
|
|
136
|
+
if (!required && equal >= 0)
|
|
137
|
+
usage(`option '--${option}' doesn't allow an argument`);
|
|
138
|
+
let value = equal < 0 ? "" : argument.slice(equal + 1);
|
|
139
|
+
if (required && equal < 0) {
|
|
140
|
+
if (++index >= context.args.length)
|
|
141
|
+
usage(`option '--${option}' requires an argument`);
|
|
142
|
+
value = context.args[index];
|
|
143
|
+
}
|
|
144
|
+
const short = { echo: "e", "input-range": "i", "head-count": "n", output: "o", repeat: "r", "zero-terminated": "z" };
|
|
145
|
+
apply(short[option] ?? option, value, index, equal < 0 ? 0 : equal + 1);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
for (let cursor = 1; cursor < argument.length; cursor++) {
|
|
149
|
+
const option = argument[cursor];
|
|
150
|
+
if (!"einorz".includes(option)) {
|
|
151
|
+
const byte = getCommandArguments(context).bytes(index)[cursor];
|
|
152
|
+
const bytes = Buffer.concat([Buffer.from("shuf: invalid option -- '"), Buffer.from([byte]), Buffer.from("'\nTry 'shuf --help' for more information.\n")]);
|
|
153
|
+
throw new Diagnostic(bytes.toString(), bytes);
|
|
154
|
+
}
|
|
155
|
+
let value = "";
|
|
156
|
+
let valueOffset = cursor + 1;
|
|
157
|
+
if ("ino".includes(option)) {
|
|
158
|
+
value = argument.slice(cursor + 1);
|
|
159
|
+
if (!value) {
|
|
160
|
+
if (++index >= context.args.length)
|
|
161
|
+
usage(`option requires an argument -- '${option}'`);
|
|
162
|
+
value = context.args[index];
|
|
163
|
+
valueOffset = 0;
|
|
164
|
+
}
|
|
165
|
+
cursor = argument.length;
|
|
166
|
+
}
|
|
167
|
+
apply(option, value, index, valueOffset);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (result.action)
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
if (result.echo && result.range)
|
|
174
|
+
usage("cannot combine -e and -i options");
|
|
175
|
+
if (result.range ? result.operands.length > 0 : !result.echo && result.operands.length > 1) {
|
|
176
|
+
usage(`extra operand ${quote(context.args[result.operands[result.range ? 0 : 1]])}`);
|
|
177
|
+
}
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CommandDefinition, VirtualShellPlugin } from "@poe-platform/safe-bash/contracts/index";
|
|
2
|
+
import type { ShufCommandsOptions } from "./options.js";
|
|
3
|
+
export { createShufCommand } from "./shuf.js";
|
|
4
|
+
export type { ShufCommandsOptions } from "./options.js";
|
|
5
|
+
export declare function createShufCommands(options?: ShufCommandsOptions): readonly CommandDefinition[];
|
|
6
|
+
export declare function shufCommands(options?: ShufCommandsOptions): VirtualShellPlugin;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createShufCommand } from "./shuf.js";
|
|
2
|
+
export { createShufCommand } from "./shuf.js";
|
|
3
|
+
export function createShufCommands(options = {}) {
|
|
4
|
+
return Object.freeze([createShufCommand(options)]);
|
|
5
|
+
}
|
|
6
|
+
export function shufCommands(options = {}) {
|
|
7
|
+
const commands = createShufCommands(options);
|
|
8
|
+
return {
|
|
9
|
+
name: "shuf-commands",
|
|
10
|
+
setup(host) {
|
|
11
|
+
if (!options.replace)
|
|
12
|
+
for (const command of commands) {
|
|
13
|
+
if (host.commands.has(command.name))
|
|
14
|
+
throw new Error(`Command already registered: ${command.name}`);
|
|
15
|
+
}
|
|
16
|
+
for (const command of commands)
|
|
17
|
+
host.commands.register(command, { replace: options.replace ?? false });
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { FsError, readBytes } from "@poe-platform/safe-bash/contracts/index";
|
|
2
|
+
import { yieldTurn } from "@poe-platform/safe-bash/contracts/yield";
|
|
3
|
+
import { Diagnostic } from "./args.js";
|
|
4
|
+
export function virtualPath(cwd, name) {
|
|
5
|
+
if (name === "")
|
|
6
|
+
throw new FsError("ENOENT");
|
|
7
|
+
return name.startsWith("/") ? name : `${cwd.endsWith("/") ? cwd : `${cwd}/`}${name}`;
|
|
8
|
+
}
|
|
9
|
+
export function ownedBytes(source, signal) {
|
|
10
|
+
const iterator = source[Symbol.asyncIterator]();
|
|
11
|
+
const controller = new AbortController();
|
|
12
|
+
const readingSignal = AbortSignal.any([signal, controller.signal]);
|
|
13
|
+
let finished = false;
|
|
14
|
+
let closing;
|
|
15
|
+
const close = () => {
|
|
16
|
+
controller.abort(new Error("shuf input is closed"));
|
|
17
|
+
return closing ??= Promise.resolve().then(async () => {
|
|
18
|
+
if (!finished && iterator.return)
|
|
19
|
+
return iterator.return();
|
|
20
|
+
return { done: true, value: undefined };
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const tracked = {
|
|
24
|
+
[Symbol.asyncIterator]() {
|
|
25
|
+
return {
|
|
26
|
+
async next() {
|
|
27
|
+
const next = await iterator.next();
|
|
28
|
+
finished = next.done === true;
|
|
29
|
+
return next;
|
|
30
|
+
},
|
|
31
|
+
return: close,
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
const stream = (async function* () {
|
|
36
|
+
let chunks = 0;
|
|
37
|
+
try {
|
|
38
|
+
for await (const chunk of readBytes(tracked, readingSignal)) {
|
|
39
|
+
yield chunk;
|
|
40
|
+
if (++chunks % 1024 === 0)
|
|
41
|
+
await yieldTurn(readingSignal);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
await close();
|
|
46
|
+
}
|
|
47
|
+
})();
|
|
48
|
+
return {
|
|
49
|
+
[Symbol.asyncIterator]() { return this; },
|
|
50
|
+
async [Symbol.asyncDispose]() { await close(); await stream.return(undefined); },
|
|
51
|
+
next: stream.next.bind(stream),
|
|
52
|
+
async return(value) { await close(); return stream.return(value); },
|
|
53
|
+
async throw(reason) { controller.abort(reason); await close(); return stream.throw(reason); },
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export async function* records(source, delimiter, limit, signal) {
|
|
57
|
+
let pending = new Uint8Array(Math.min(256, limit));
|
|
58
|
+
let used = 0;
|
|
59
|
+
let scanned = 0;
|
|
60
|
+
for await (const chunk of source) {
|
|
61
|
+
let start = 0;
|
|
62
|
+
while (start < chunk.length) {
|
|
63
|
+
signal.throwIfAborted();
|
|
64
|
+
const boundary = chunk.indexOf(delimiter, start);
|
|
65
|
+
const end = boundary < 0 ? chunk.length : boundary + 1;
|
|
66
|
+
const needed = used + end - start;
|
|
67
|
+
if (needed > limit)
|
|
68
|
+
throw new Diagnostic("shuf: maxInputBytes limit exceeded\n");
|
|
69
|
+
if (pending.length < needed) {
|
|
70
|
+
const grown = new Uint8Array(Math.min(limit, Math.max(needed, pending.length * 2)));
|
|
71
|
+
grown.set(pending.subarray(0, used));
|
|
72
|
+
pending = grown;
|
|
73
|
+
}
|
|
74
|
+
pending.set(chunk.subarray(start, end), used);
|
|
75
|
+
used = needed;
|
|
76
|
+
start = end;
|
|
77
|
+
if (boundary >= 0) {
|
|
78
|
+
yield pending.slice(0, used);
|
|
79
|
+
used = 0;
|
|
80
|
+
}
|
|
81
|
+
if (++scanned % 1024 === 0)
|
|
82
|
+
await yieldTurn(signal);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (used) {
|
|
86
|
+
if (used >= limit)
|
|
87
|
+
throw new Diagnostic("shuf: maxInputBytes limit exceeded\n");
|
|
88
|
+
const last = new Uint8Array(used + 1);
|
|
89
|
+
last.set(pending.subarray(0, used));
|
|
90
|
+
last[used] = delimiter;
|
|
91
|
+
yield last;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ShufCommandsOptions {
|
|
2
|
+
readonly replace?: boolean;
|
|
3
|
+
readonly maxInputBytes?: number;
|
|
4
|
+
readonly maxSampleSize?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function settings(options: ShufCommandsOptions): Readonly<{
|
|
7
|
+
maxInputBytes: number;
|
|
8
|
+
maxSampleSize: number;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function settings(options) {
|
|
2
|
+
const limits = { maxInputBytes: options.maxInputBytes ?? 64 * 1024 * 1024, maxSampleSize: options.maxSampleSize ?? 1_000_000 };
|
|
3
|
+
for (const [name, value] of Object.entries(limits)) {
|
|
4
|
+
if (!Number.isSafeInteger(value) || value < 1)
|
|
5
|
+
throw new RangeError(`Invalid shuf ${name}`);
|
|
6
|
+
}
|
|
7
|
+
return Object.freeze(limits);
|
|
8
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { randomFillSync } from "node:crypto";
|
|
2
|
+
import { yieldTurn } from "@poe-platform/safe-bash/contracts/yield";
|
|
3
|
+
import { Diagnostic, quote, wordMax } from "./args.js";
|
|
4
|
+
import { ownedBytes, virtualPath } from "./input.js";
|
|
5
|
+
export class RandomIntegers {
|
|
6
|
+
context;
|
|
7
|
+
name;
|
|
8
|
+
maxBytes;
|
|
9
|
+
value = 0n;
|
|
10
|
+
maximum = 0n;
|
|
11
|
+
bytes = new Uint8Array();
|
|
12
|
+
offset = 0;
|
|
13
|
+
source;
|
|
14
|
+
closed = false;
|
|
15
|
+
closing;
|
|
16
|
+
opening;
|
|
17
|
+
controller = new AbortController();
|
|
18
|
+
signal;
|
|
19
|
+
constructor(context, name, maxBytes = 64 * 1024 * 1024) {
|
|
20
|
+
this.context = context;
|
|
21
|
+
this.name = name;
|
|
22
|
+
this.maxBytes = maxBytes;
|
|
23
|
+
this.signal = AbortSignal.any([context.signal, this.controller.signal]);
|
|
24
|
+
context.registerCleanup?.(() => this.close());
|
|
25
|
+
}
|
|
26
|
+
open() {
|
|
27
|
+
if (this.closed)
|
|
28
|
+
return Promise.reject(this.signal.reason);
|
|
29
|
+
return this.opening ??= Promise.resolve().then(async () => {
|
|
30
|
+
const { fs } = this.context;
|
|
31
|
+
const signal = this.signal;
|
|
32
|
+
signal.throwIfAborted();
|
|
33
|
+
if (this.name === undefined)
|
|
34
|
+
return;
|
|
35
|
+
const path = virtualPath(this.context.cwd, this.name);
|
|
36
|
+
await fs.access(path, 4, { signal });
|
|
37
|
+
signal.throwIfAborted();
|
|
38
|
+
if (fs.readStream)
|
|
39
|
+
this.source = ownedBytes(fs.readStream(path, { signal, chunkSize: Math.min(4096, this.maxBytes) }), signal);
|
|
40
|
+
else {
|
|
41
|
+
const maxBytes = this.maxBytes;
|
|
42
|
+
this.source = ownedBytes((async function* () {
|
|
43
|
+
const bytes = await fs.readFile(path, { signal, maxBytes });
|
|
44
|
+
if (bytes.byteLength > maxBytes)
|
|
45
|
+
throw new Diagnostic("shuf: maxInputBytes limit exceeded\n");
|
|
46
|
+
yield bytes;
|
|
47
|
+
})(), signal);
|
|
48
|
+
}
|
|
49
|
+
signal.throwIfAborted();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async close() {
|
|
53
|
+
this.closed = true;
|
|
54
|
+
this.controller.abort(new Error("shuf random source is closed"));
|
|
55
|
+
return this.closing ??= (async () => {
|
|
56
|
+
await this.opening?.catch(() => { });
|
|
57
|
+
await this.source?.return(undefined);
|
|
58
|
+
this.bytes.fill(0);
|
|
59
|
+
this.value = this.maximum = 0n;
|
|
60
|
+
})();
|
|
61
|
+
}
|
|
62
|
+
async byte() {
|
|
63
|
+
this.signal.throwIfAborted();
|
|
64
|
+
if (this.closed)
|
|
65
|
+
throw new Error("shuf random source is closed");
|
|
66
|
+
while (this.offset === this.bytes.length) {
|
|
67
|
+
if (this.source) {
|
|
68
|
+
const next = await this.source.next();
|
|
69
|
+
this.signal.throwIfAborted();
|
|
70
|
+
if (next.done)
|
|
71
|
+
throw new Diagnostic(`shuf: ${quote(this.name)}: end of file\n`);
|
|
72
|
+
if (next.value.byteLength > this.maxBytes)
|
|
73
|
+
throw new Diagnostic("shuf: maxInputBytes limit exceeded\n");
|
|
74
|
+
this.bytes = new Uint8Array(next.value);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this.bytes = randomFillSync(new Uint8Array(4096));
|
|
78
|
+
}
|
|
79
|
+
this.offset = 0;
|
|
80
|
+
this.signal.throwIfAborted();
|
|
81
|
+
}
|
|
82
|
+
return this.bytes[this.offset++];
|
|
83
|
+
}
|
|
84
|
+
async choose(size) {
|
|
85
|
+
if (size < 1n || size > wordMax)
|
|
86
|
+
throw new RangeError("shuf choice size out of range");
|
|
87
|
+
const target = size - 1n;
|
|
88
|
+
let attempts = 0;
|
|
89
|
+
while (true) {
|
|
90
|
+
this.signal.throwIfAborted();
|
|
91
|
+
if (++attempts % 256 === 0)
|
|
92
|
+
await yieldTurn(this.signal);
|
|
93
|
+
while (this.maximum < target) {
|
|
94
|
+
this.value = ((this.value << 8n) + BigInt(await this.byte())) & wordMax;
|
|
95
|
+
this.maximum = ((this.maximum << 8n) + 255n) & wordMax;
|
|
96
|
+
}
|
|
97
|
+
if (this.maximum === target) {
|
|
98
|
+
const chosen = this.value;
|
|
99
|
+
this.value = this.maximum = 0n;
|
|
100
|
+
return chosen;
|
|
101
|
+
}
|
|
102
|
+
const excess = this.maximum - target;
|
|
103
|
+
const unusable = excess % size;
|
|
104
|
+
const remainder = this.value % size;
|
|
105
|
+
if (this.value <= this.maximum - unusable) {
|
|
106
|
+
this.value /= size;
|
|
107
|
+
this.maximum = excess / size;
|
|
108
|
+
return remainder;
|
|
109
|
+
}
|
|
110
|
+
this.value = remainder;
|
|
111
|
+
this.maximum = unusable - 1n;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|