/** 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 rest = argv.slice(1) let createNew = false if (rest[0] === '--new') { createNew = true rest.shift() } const passphrase = rest.join(' ') if (!passphrase) { ctx.console.error('usage: login [--new] ') return } const reg = ctx.applyRegister const unlock = ctx.applyUnlock if (typeof reg !== 'function' || typeof unlock !== 'function') { ctx.console.error('login: not supported in this environment') return } try { if (createNew) await reg.call(ctx, passphrase) else await unlock.call(ctx, passphrase) } catch (err) { ctx.console.error(err?.message ?? String(err)) } }