diff --git a/src/manager.ts b/src/manager.ts index ecf42c0..a4b0f49 100644 --- a/src/manager.ts +++ b/src/manager.ts @@ -2,7 +2,7 @@ import * as path from 'path'; import type { Client, ClientChannel } from 'ssh2'; import * as vscode from 'vscode'; -import { getConfig, loadConfigsRaw } from './config'; +import { getConfig, getFlagBoolean, loadConfigsRaw } from './config'; import { Connection, ConnectionManager } from './connection'; import type { FileSystemConfig } from './fileSystemConfig'; import { getRemotePath } from './fileSystemRouter'; @@ -183,8 +183,10 @@ export class Manager implements vscode.TaskProvider, vscode.TerminalLinkProvider const connection = await this.connectionManager.createConnection(resolved.host); resolved = await replaceVariablesRecursive(resolved, value => replaceVariables(value, connection.actualConfig)); let { command, workingDirectory } = resolved; + const [useWinCmdSep] = getFlagBoolean('WINDOWS_COMMAND_SEPARATOR', false, connection.actualConfig.flags); + const separator = useWinCmdSep ? ' && ' : '; '; let { taskCommand = '$COMMAND' } = connection.actualConfig; - taskCommand = joinCommands(taskCommand)!; + taskCommand = joinCommands(taskCommand, separator)!; if (taskCommand.includes('$COMMAND')) { command = taskCommand.replace(/\$COMMAND/g, command); } else { diff --git a/src/pseudoTerminal.ts b/src/pseudoTerminal.ts index 4611629..9e4680b 100644 --- a/src/pseudoTerminal.ts +++ b/src/pseudoTerminal.ts @@ -2,6 +2,7 @@ import * as path from 'path'; import type { Client, ClientChannel, PseudoTtyOptions } from "ssh2"; import type { Readable } from "stream"; import * as vscode from "vscode"; +import { getFlagBoolean } from './config'; import type { FileSystemConfig } from "./fileSystemConfig"; import { getRemotePath } from './fileSystemRouter'; import { Logging, LOGGING_NO_STACKTRACE } from "./logging"; @@ -39,10 +40,10 @@ export interface TerminalOptions { command?: string; } -export function joinCommands(commands?: string | string[]): string | undefined { +export function joinCommands(commands: string | string[] | undefined, separator: string): string | undefined { if (!commands) return undefined; if (typeof commands === 'string') return commands; - return commands.join('; '); + return commands.join(separator); } @@ -169,11 +170,13 @@ export async function createTerminal(options: TerminalOptions): Promise(cb => client.exec(joinCommands(commands)!, { pty: pseudoTtyOptions }, cb)); + const channel = await toPromise(cb => client.exec(joinCommands(commands, separator)!, { pty: pseudoTtyOptions }, cb)); if (!channel) throw new Error('Could not create remote terminal'); pseudo.channel = channel; channel.on('exit', onDidClose.fire);