13
*/
14
export function escapeNonWindowsPath(path: string, shellType?: TerminalShellType): string {
16
>
if (newPath.includes('\\')) {
17
newPath = newPath.replace(/\\/g, '\\\\');
18
}
20
>
// Define shell-specific escaping rules
21
>
interface ShellEscapeConfig {
22
>
// How to handle paths with both single and double quotes
23
>
bothQuotes: (path: string) => string;
24
>
// How to handle paths with only single quotes
25
>
singleQuotes: (path: string) => string;
26
>
// How to handle paths with no single quotes (may have double quotes)
27
>
noSingleQuotes: (path: string) => string;
28
>
}
29
>
30
>
let escapeConfig: ShellEscapeConfig;
31
>
switch (shellType) {
32
>
case PosixShellType.Bash:
33
>
case PosixShellType.Sh:
34
>
case PosixShellType.Zsh:
35
>
case WindowsShellType.GitBash:
36
escapeConfig = {
37
bothQuotes: (path) => `$'${path.replace(/'/g, '\\\'')}'`,