This commit is contained in:
Raven Scott
2026-04-03 03:07:51 -04:00
parent 342b6040fe
commit d794c87b32
19 changed files with 823 additions and 18 deletions
+79
View File
@@ -0,0 +1,79 @@
/** 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 vfs = ctx.vfs
const home = vfs.env?.HOME || '/home/guest'
const h = String(home).replace(/\/$/, '')
const tabPath = `${h}/.crontab`
const rest = argv.slice(1)
if (rest.length === 0) {
ctx.console.error('crontab: usage: crontab -l | crontab -r | crontab <file>')
ctx.exitCode = 1
return
}
if (rest[0] === '-l') {
try {
const b = await vfs.readFile(tabPath)
if (!b || !b.length) {
ctx.console.log('no crontab for user')
return
}
const s = ctx.b4a.toString(b)
ctx.console.log(s.endsWith('\n') ? s : s + '\n')
} catch {
ctx.console.log('no crontab for user')
}
return
}
if (rest[0] === '-r') {
if (ctx.identity?.state !== 'unlocked') {
ctx.console.error('crontab: log in to modify crontab')
ctx.exitCode = 1
return
}
try {
await vfs.unlink(tabPath)
} catch (e) {
const msg = String(e?.message || e)
if (/not found|ENOENT|no entry|missing/i.test(msg)) {
ctx.console.error('crontab: no crontab for user')
} else {
ctx.console.error('crontab: ' + msg)
}
ctx.exitCode = 1
}
return
}
if (rest[0].startsWith('-')) {
ctx.console.error('crontab: unknown option ' + rest[0])
ctx.exitCode = 1
return
}
if (ctx.identity?.state !== 'unlocked') {
ctx.console.error('crontab: log in to install crontab')
ctx.exitCode = 1
return
}
const file = rest[0]
try {
const b = await vfs.readFile(file)
if (b == null) {
ctx.console.error('crontab: ' + file + ': cannot read')
ctx.exitCode = 1
return
}
await vfs.writeFile(tabPath, b)
} catch (e) {
ctx.console.error('crontab: ' + (e.message || e))
ctx.exitCode = 1
}
}
+1 -1
View File
@@ -5,7 +5,7 @@ function bareStdin(ctx) {
async function run(ctx, argv) {
ctx.console.log(
'Bare OS — default user: guest | builtins: cd, export, exit, login, logout | /bin: basename cat clear date dirname echo env exit false head hdms help hostname id login logout ls nl pathchk printenv pwd rm savevault seq sleep sort tail test touch true tty uname wc which whoami'
'Bare OS — default user: guest | builtins: cd, export, exit, login, logout | /bin: basename cat clear crontab date dirname echo env exit false head hdms help hostname id login logout ls nl pathchk printenv pwd rm savevault seq sleep sort tail test touch true tty uname wc which whoami'
)
ctx.console.log(
'Identity: login [--new] <passphrase> | logout [--save] | savevault (encrypt copy of personal drive under /.bare/vault/)'
+2 -1
View File
@@ -36,7 +36,8 @@ async function run(ctx, argv) {
ctx.console.error('ls: cannot access ' + t + ': ' + (e.message || e))
continue
}
if (!showAll) names = names.filter((n) => n !== '.' && n !== '..')
// POSIX: hide dotfiles unless -a (. and .. are dot-prefixed too).
if (!showAll) names = names.filter((n) => !n.startsWith('.'))
if (!longFmt) {
ctx.console.log(names.join(' '))
} else {