core utils updates
This commit is contained in:
+32
-1
@@ -60,6 +60,33 @@ function barePosixBlocks(size) {
|
||||
return Math.ceil(Number(size) / 512) || 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Raw stdout for NUL/binary when **`process.stdout.write`** is missing.
|
||||
* If **`ctx.bareOsBinWrite(Uint8Array|string)`** is set (tests / host), use it.
|
||||
* @param {Record<string, unknown>} ctx
|
||||
* @param {string | Uint8Array} chunk
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function bareOsEmitRaw(ctx, chunk) {
|
||||
if (typeof ctx.bareOsBinWrite === 'function') {
|
||||
const b4 = ctx.b4a
|
||||
const u8 =
|
||||
typeof chunk === 'string'
|
||||
? b4 && typeof b4.from === 'function'
|
||||
? b4.from(chunk)
|
||||
: new TextEncoder().encode(chunk)
|
||||
: chunk
|
||||
ctx.bareOsBinWrite(u8 instanceof Uint8Array ? u8 : new Uint8Array(u8))
|
||||
return true
|
||||
}
|
||||
const w = globalThis.process?.stdout?.write
|
||||
if (typeof w === 'function') {
|
||||
w.call(globalThis.process.stdout, chunk)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Subset of POSIX.1-2017 getconf — fixed values for Bare OS (no host sysconf).
|
||||
* Unknown names exit with status 1 (matches common getconf for invalid var).
|
||||
@@ -85,7 +112,11 @@ const CONF = {
|
||||
_POSIX_JOB_CONTROL: '0',
|
||||
_POSIX_SAVED_IDS: '0',
|
||||
/** Bare shell line length (reasonable REPL limit, not a hard kernel cap). */
|
||||
BARE_OS_INPUT_LINE_MAX: '8192'
|
||||
BARE_OS_INPUT_LINE_MAX: '8192',
|
||||
/** Defaults for simulated pipelines (override with BARE_OS_PIPELINE_* env); see handbook §3. */
|
||||
BARE_OS_PIPELINE_MAX_STAGES: '32',
|
||||
BARE_OS_PIPELINE_MAX_BYTES: '2097152',
|
||||
BARE_OS_PIPELINE_MAX_LINES: '50000'
|
||||
}
|
||||
|
||||
async function run(ctx, argv) {
|
||||
|
||||
Reference in New Issue
Block a user