From d4620832c6a50b43f30ebebd6b9c0e8ea68e7e1d Mon Sep 17 00:00:00 2001 From: Jarkko Linnanvirta Date: Sat, 11 Mar 2023 18:46:50 +0200 Subject: [PATCH] #297: CustomShell: Show an error if binary path is empty. --- src/shells/CustomShell.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/shells/CustomShell.ts b/src/shells/CustomShell.ts index 0139ea7..c1b824e 100644 --- a/src/shells/CustomShell.ts +++ b/src/shells/CustomShell.ts @@ -156,6 +156,12 @@ export class CustomShell extends Shell { protected async augmentSpawn(spawnAugmentation: SpawnAugmentation, tShellCommand: TShellCommand | null, scEvent: SC_Event | null): Promise { const debugLogBase = this.constructor.name + ".augmentSpawn(): "; + const shellBinaryPath = this.getBinaryPath(); + if ("" === shellBinaryPath.trim()) { + // Shell binary is not specified. + this.plugin.newError("Custom shell " + this.getName() + ": Binary path is not defined."); + return false; // Prevent execution. + } // Disable Node.js's builtin shell feature. // CustomShells need to be able to define their own shell invoking command line options, so the Node.js's shell feature would be too limited. @@ -202,7 +208,7 @@ export class CustomShell extends Shell { spawnAugmentation.spawnArguments = parsedShellArguments; // Tell spawn() to use the shell binary path as an executable command. - spawnAugmentation.shellCommandContent = this.getBinaryPath(); // Needs to come AFTER the original shellCommandContent is taken to spawnArguments! + spawnAugmentation.shellCommandContent = shellBinaryPath; // Needs to come AFTER the original shellCommandContent is taken to spawnArguments! return true; // Allow execution. }