Skip to main content

Function: escapeShellArg()

escapeShellArg(arg): string

Defined in: packages/core/src/utils/shell-security.ts:85

Quote a string as one shell argument: single quotes, with each embedded single quote closed, escaped and reopened.

Parameters​

arg​

string

Returns​

string

Example​

const filename = "user's file.txt";
const escaped = escapeShellArg(filename);
// Returns: 'user'\''s file.txt'