shellWord

tcmts.cli.ui.shellWord · #ijtvgmy7 · term · runs anywhere

s as one word of a shell command: quoted if it has to be (a path with a space in it).

export function shellWord(s: string): string {
  return /^[\w@%+=:,./-]+$/.test(s) ? s : `'${s.replaceAll("'", `'\\''`)}'`;
}

used by