Skip to content

escapeCommand

escapeCommand(cmd, dialect): string

Defined in: command/shell-dialect.ts:50

Escape any characters in a string that might be used to trick a command line written in the given dialect into executing arbitrary commands.

Prefer escapeCommandArg whenever the string is one argument rather than a whole command: neutralizing metacharacters leaves a string that the shell still splits on whitespace.

string

The command to escape

ShellDialect

The shell language the command is written in

string

The escaped command