Skip to main content

shell_quote

Function shell_quote 

Source
fn shell_quote(s: &str) -> String
Expand description

Quote a value for embedding in a shell argv position.

The tool-use-id is provider-generated and currently always opaque ASCII, but be defensive: if it contains a non-safe char, escape per the host shell’s rules.

  • Unix shells (bash/sh/zsh): single-quote wrap with '\'' escape for embedded single quotes.
  • Windows cmd.exe /C: cmd doesn’t interpret single quotes as quoting; we use double quotes and escape embedded " per cmd.exe rules. This is the shell Claude Code’s Bash tool invokes on Win32.

Pure-alphanumeric ids return unchanged on every platform.