21 lines
536 B
Plaintext
21 lines
536 B
Plaintext
/** Shared helpers for drive-resident /bin scripts (prepended before each command). */
|
|
function bareStdin(ctx) {
|
|
return typeof ctx.shellStdin === 'string' ? ctx.shellStdin : ''
|
|
}
|
|
|
|
async function run(ctx, argv) {
|
|
const parts = argv.slice(1)
|
|
let n = false
|
|
if (parts[0] === '-n') {
|
|
n = true
|
|
parts.shift()
|
|
}
|
|
const s = parts.join(' ')
|
|
const w = globalThis.process?.stdout?.write
|
|
if (typeof w === 'function') {
|
|
w.call(globalThis.process.stdout, s + (n ? '' : '\n'))
|
|
} else {
|
|
ctx.console.log(n ? s : s)
|
|
}
|
|
}
|