This commit is contained in:
Raven Scott
2026-04-03 04:01:24 -04:00
parent 8505077f8d
commit 98259a7b4a
23 changed files with 2371 additions and 66 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
async function run(ctx, argv) {
ctx.console.log(
'Bare OS — default user: guest | builtins: cd, export, exit, login, logout | /bin: basename cat clear crontab date dirname echo env exit false grep 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: alias, cd, export, exit, login, logout, unalias | /bin: basename cat clear crontab date dirname echo env exit false git grep 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/)'
+32 -2
View File
@@ -1,4 +1,11 @@
/**
* rm — remove files or directories.
* Flags: -r -R --recursive, -f --force, -- ; bundled e.g. -rf
*/
async function run(ctx, argv) {
const vfs = ctx.vfs
let recursive = false
let force = false
const files = []
let dash = false
for (let i = 1; i < argv.length; i++) {
@@ -11,7 +18,22 @@ async function run(ctx, argv) {
dash = true
continue
}
if (a.startsWith('-')) continue
if (a === '--recursive' || a === '-r' || a === '-R') {
recursive = true
continue
}
if (a === '--force' || a === '-f') {
force = true
continue
}
if (a.startsWith('-') && a.length > 1) {
for (let j = 1; j < a.length; j++) {
const c = a[j]
if (c === 'r' || c === 'R') recursive = true
else if (c === 'f') force = true
}
continue
}
files.push(a)
}
if (!files.length) {
@@ -19,10 +41,18 @@ async function run(ctx, argv) {
ctx.exitCode = 1
return
}
const doRm =
vfs && typeof vfs.rm === 'function'
? (p) => vfs.rm(p, { recursive, force })
: async (p) => {
if (recursive) throw new Error('recursive rm not supported')
return vfs.unlink(p)
}
for (const f of files) {
try {
await ctx.vfs.unlink(f)
await doRm(f)
} catch (e) {
if (force) continue
ctx.console.error('rm: ' + f + ': ' + (e.message || e))
ctx.exitCode = 1
}