updates
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
/** 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 files = []
|
||||
let dash = false
|
||||
for (let i = 1; i < argv.length; i++) {
|
||||
const a = argv[i]
|
||||
if (dash) {
|
||||
files.push(a)
|
||||
continue
|
||||
}
|
||||
if (a === '--') {
|
||||
dash = true
|
||||
continue
|
||||
}
|
||||
if (a.startsWith('-')) continue
|
||||
files.push(a)
|
||||
}
|
||||
if (!files.length) {
|
||||
ctx.console.error('rm: missing operand')
|
||||
ctx.exitCode = 1
|
||||
return
|
||||
}
|
||||
for (const f of files) {
|
||||
try {
|
||||
await ctx.vfs.unlink(f)
|
||||
} catch (e) {
|
||||
ctx.console.error('rm: ' + f + ': ' + (e.message || e))
|
||||
ctx.exitCode = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user