@@ -0,0 +1,22 @@
|
||||
/** 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 files = argv.slice(1)
|
||||
if (!files.length) {
|
||||
const s = bareStdin(ctx)
|
||||
ctx.console.log(s)
|
||||
return
|
||||
}
|
||||
for (const f of files) {
|
||||
const buf = await vfs.readFile(f)
|
||||
if (!buf) {
|
||||
ctx.console.error('cat: ' + f + ': No such file or directory')
|
||||
continue
|
||||
}
|
||||
ctx.console.log(ctx.b4a.toString(buf))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user