Files
bare-operating-system/packages/bare-os-seeder/kernel/bin/uname
T
Raven Scott 2e26b14250
CI / test (push) Failing after 4m56s
updates
2026-04-02 22:35:09 -04:00

38 lines
1.2 KiB
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 flagArgs = argv.slice(1).filter((a) => a.startsWith('-') && a !== '--')
const all = argv.includes('-a')
const noFlag = flagArgs.length === 0
const wantS = all || argv.includes('-s') || noFlag
const wantN = all || argv.includes('-n')
const wantR = all || argv.includes('-r')
const wantM = all || argv.includes('-m')
const wantV = all || argv.includes('-v')
let name = 'BareOS'
let version = '0.1'
const buf = await ctx.vfs.readFile('/etc/os-release')
if (buf) {
const t = ctx.b4a.toString(buf)
for (const line of t.split('\n')) {
const id = line.match(/^NAME=(.*)$/)
if (id) name = id[1].replace(/^"|"$/g, '')
const ver = line.match(/^VERSION=(.*)$/)
if (ver) version = ver[1].replace(/^"|"$/g, '')
}
}
const parts = []
if (wantS) parts.push(name)
if (wantN) parts.push('bare-os')
if (wantR) parts.push(version)
if (wantV) parts.push('bare-userland')
if (wantM) parts.push('unknown')
ctx.console.log(parts.join(' '))
}