MCPcopy Create free account
hub / github.com/Marus/cortex-debug / quoteShellAndCmdChars

Function quoteShellAndCmdChars

src/common.ts:700–704  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

698// where will need to put the string in quotes as a precaution. This is more a printing
699// aid rather an using for an API
700export function quoteShellAndCmdChars(s): string {
701 const quote = /[\s\"\*\[\]!@#$%^&*\(\)\\:]/g.test(s) ? '"' : '';
702 s = s.replace(/"/g, '\\"').replace(/\\/g, '\\\\');
703 return quote + s.replace(/"/g, '\\"') + quote;
704}
705
706export function quoteShellCmdLine(list: string[]): string {
707 return list.map((s) => quoteShellAndCmdChars(s)).join(' ');

Callers 1

quoteShellCmdLineFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected