47 lines
1008 B
Plaintext
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 +
|
|
')'
|
|
)
|
|
}
|