diff --git a/packages/shell-evaluator/src/shell-evaluator.spec.ts b/packages/shell-evaluator/src/shell-evaluator.spec.ts index f9cf1ef46b..c11bf837c3 100644 --- a/packages/shell-evaluator/src/shell-evaluator.spec.ts +++ b/packages/shell-evaluator/src/shell-evaluator.spec.ts @@ -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;', {}, ''); diff --git a/packages/shell-evaluator/src/shell-evaluator.ts b/packages/shell-evaluator/src/shell-evaluator.ts index 2c0a5714b1..14aa90632e 100644 --- a/packages/shell-evaluator/src/shell-evaluator.ts +++ b/packages/shell-evaluator/src/shell-evaluator.ts @@ -36,7 +36,7 @@ class ShellEvaluator { 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); }