updates
CI / test (push) Failing after 4m57s

This commit is contained in:
Raven Scott
2026-04-02 22:43:46 -04:00
parent 2e26b14250
commit c337a8aaa6
62 changed files with 1099 additions and 23 deletions
+30
View File
@@ -0,0 +1,30 @@
/** 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 vfs = ctx.vfs
const files = argv.slice(1).filter((a) => !a.startsWith('-'))
/** @type {string[]} */
let lines = []
if (!files.length) {
const s = bareStdin(ctx)
lines = s.length ? s.split('\n') : []
if (lines.length && lines[lines.length - 1] === '') lines.pop()
} else {
for (const f of files) {
const buf = await vfs.readFile(f)
if (!buf) {
ctx.console.error('sort: ' + f + ': No such file')
ctx.exitCode = 1
continue
}
const part = ctx.b4a.toString(buf).split('\n')
if (part.length && part[part.length - 1] === '') part.pop()
lines.push(...part)
}
}
lines.sort((x, y) => (x < y ? -1 : x > y ? 1 : 0))
if (lines.length) ctx.console.log(lines.join('\n'))
}