Files
bare-operating-system/packages/bare-os-seeder/kernel/bin/touch
T
2026-04-02 22:43:46 -04:00

23 lines
657 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 files = argv.slice(1).filter((a) => !a.startsWith('-'))
if (!files.length) {
ctx.console.error('touch: missing file operand')
ctx.exitCode = 1
return
}
for (const f of files) {
try {
const existing = await ctx.vfs.readFile(f)
await ctx.vfs.writeFile(f, existing || ctx.b4a.from(''))
} catch (e) {
ctx.console.error('touch: ' + f + ': ' + (e.message || e))
ctx.exitCode = 1
}
}
}