Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
/**
* POSIX single-quote any arg that isn't already shell-safe, so `$()`, backticks,
* etc. in a token are inert literals when the block is pasted into a shell
* (double-quoting would still allow command substitution). A leaf module:
* importing it adds no other module's text to a command's flag-registry scan.
*/
export function shellQuote(arg: string): string {
if (/^[A-Za-z0-9_.:/@-]+$/.test(arg)) return arg;
return `'${arg.replace(/'/g, "'\\''")}'`;
}