Files
bare-operating-system/packages/bare-os-seeder/kernel/bin/id
T
Raven Scott c337a8aaa6
CI / test (push) Failing after 4m57s
updates
2026-04-02 22:43:46 -04:00

47 lines
1008 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 u = ctx.vfs.env.USER || 'user'
const uid = ctx.vfs.env.UID || '1000'
const gid = ctx.vfs.env.GID || '1000'
const g = ctx.vfs.env.GROUP || u
const rest = argv.slice(1)
const wantG = rest.includes('-g') || rest.includes('--group')
const wantU = rest.includes('-u') || rest.includes('--user')
const wantN = rest.includes('-n') || rest.includes('--name')
if (wantU && wantN) {
ctx.console.log(u)
return
}
if (wantG && wantN) {
ctx.console.log(g)
return
}
if (wantU) {
ctx.console.log(uid)
return
}
if (wantG) {
ctx.console.log(gid)
return
}
ctx.console.log(
'uid=' +
uid +
'(' +
u +
') gid=' +
gid +
'(' +
g +
') groups=' +
gid +
'(' +
g +
')'
)
}