cmdEscapeCommandLine
Escapes cmd.exe metacharacters with ^ so that cmd.exe passes them through literally. This is necessary because cmd.exe’s " handling differs from CommandLineToArgvW and cannot be relied upon.
Apply this to a command line string that will be executed via cmd.exe (e.g., spawn(cmd, [], { shell: true }) on Windows).
Import:
import { cmdEscapeCommandLine } from 'obsidian-dev-utils/script-utils/cli-utils';Signature:
function cmdEscapeCommandLine(commandLine: string): stringParameters:
| Parameter | Type | Description |
|---|---|---|
commandLine | string | The already-quoted command line string. |
Returns: string — The string with all cmd metacharacters ^-escaped.
Links to this page: