shell: add explicit bash() function

This commit is contained in:
Girish Ramakrishnan
2024-10-16 10:25:07 +02:00
parent d66db8ca40
commit df5ba25010
10 changed files with 46 additions and 63 deletions
+8 -5
View File
@@ -64,14 +64,17 @@ describe('shell', function () {
const [error] = await safe(shell.spawn('sleep', ['20'], { timeout: 1000 }));
expect(error.reason).to.be(BoxError.SHELL_ERROR);
});
});
it('cannot exec a shell program by default', async function () {
const [error] = await safe(shell.exec('ls -l | wc -c', {}));
expect(error.reason).to.be(BoxError.SHELL_ERROR);
describe('bash', function () {
it('can bash a shell program', async function () {
const out = await shell.bash('ls -l | wc -c', {});
expect(Buffer.isBuffer(out)).to.be(true);
});
it('cannot exec a shell program b', async function () {
await shell.exec('ls -l | wc -c', { shell: '/bin/bash' });
it('can bash a shell program', async function () {
const out = await shell.bash('ls -l | wc -c', { encoding: 'utf8' });
expect(out).to.be.a('string');
});
});
});