Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/shell-evaluator/src/shell-evaluator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ describe('ShellEvaluator', () => {
expect(useSpy).to.have.been.calledWith('somedb');
});

it('does not apply special handling for commands when the first argument starts with (', async() => {
const originalEval = sinon.spy();
await shellEvaluator.customEval(originalEval, 'use (somedb);', {}, '');
expect(originalEval.firstCall.args[0]).to.include('somedb');
expect(useSpy).to.have.callCount(0);
});

it('forwards show commands', async() => {
const dontCallEval = () => { throw new Error('unreachable'); };
await shellEvaluator.customEval(dontCallEval, 'show dbs;', {}, '');
Expand Down
2 changes: 1 addition & 1 deletion packages/shell-evaluator/src/shell-evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ShellEvaluator<EvaluationResultType = ShellResult> {
const { shellApi } = this.internalState;
const argv = input.trim().replace(/;$/, '').split(/\s+/g);
const cmd = argv.shift() as keyof typeof shellApi;
if (shellApi[cmd]?.isDirectShellCommand) {
if (shellApi[cmd]?.isDirectShellCommand && !(argv[0] ?? '').startsWith('(')) {
return shellApi[cmd](...argv);
}

Expand Down