Added consistent non-empty version output for:
curl --version in packages/bare-os-coreutils/src/curl.js wget --version in packages/bare-os-coreutils/src/wget.js openssl version and openssl --version in packages/bare-os-coreutils/src/openssl.js nano --version (via edit) in packages/bare-os-coreutils/src/edit.js Updated tar compatibility in packages/bare-os-booter/lib/tar-cli.js: Added tar --version Added grouped short-flag parsing (-czf, etc.) Added first-arg legacy cluster parsing (czf) Added - archive target support for create/list/extract stream paths Kept implementation as ustar subset (accepts z for compatibility parsing) Fixed pipeline/timeout behavior: Optimized head line mode to stop scanning early (no full split) in packages/bare-os-coreutils/src/head.js Added bounded safety for yes cap in packages/bare-os-coreutils/src/yes.js Hardened timeout so timed-out commands reliably produce exit code 124 in packages/bare-os-coreutils/src/timeout.js Added scoped expr compatibility in shell: Prevented pathname expansion of bare * only for expr arithmetic-token case in packages/bare-os-booter/lib/shell.js Added glob option plumbing in packages/bare-os-booter/lib/shell-glob.js
This commit is contained in:
+15
-5
@@ -162,6 +162,19 @@ async function run(ctx, argv) {
|
||||
|
||||
const files = argv.slice(i).filter((x) => x !== '--')
|
||||
|
||||
const takeFirstLines = (s, maxLines) => {
|
||||
if (maxLines <= 0 || !s) return ''
|
||||
let idx = 0
|
||||
let seen = 0
|
||||
while (seen < maxLines) {
|
||||
const nl = s.indexOf('\n', idx)
|
||||
if (nl === -1) return s
|
||||
seen++
|
||||
idx = nl + 1
|
||||
}
|
||||
return s.slice(0, idx)
|
||||
}
|
||||
|
||||
const takeString = (s) => {
|
||||
if (mode === 'bytes') {
|
||||
const u8 = ctx.b4a.from(s, 'utf8')
|
||||
@@ -170,11 +183,8 @@ async function run(ctx, argv) {
|
||||
if (out) ctx.console.log(out)
|
||||
return
|
||||
}
|
||||
const lines = s.split('\n')
|
||||
const out = lines.slice(0, n).join('\n')
|
||||
ctx.console.log(
|
||||
out + (out && !out.endsWith('\n') && lines.length > n ? '\n' : '')
|
||||
)
|
||||
const out = takeFirstLines(s, n)
|
||||
if (out) ctx.console.log(out)
|
||||
}
|
||||
|
||||
const takeU8 = (u8) => {
|
||||
|
||||
Reference in New Issue
Block a user