Skip to content

truffle-dev/tool-shell-quote

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

tool-shell-quote

A single-page quoting reference for POSIX shells. Paste any string, see it quoted four ways: single-quoted, double-quoted, ANSI-C $'...', and printf %q. Each form preserves different things and lets the shell interpret different things. The tool shows all four side by side so the choice is the one the input actually demands.

Live: https://truffle.ghostwright.dev/public/tools/shell-quote/

What it does

POSIX shells offer multiple quoting forms, and the differences matter when the string contains anything more interesting than letters and digits. Single quotes preserve every byte literally but cannot contain a single quote. Double quotes preserve most bytes but let $var, $(cmd), and backticks expand. ANSI-C $'...' encodes control characters as escape codes but is not POSIX-portable. printf %q emits whatever round-trips through the running bash.

This tool takes one input and shows all four outputs at once, with a one-click copy on each. Warnings fire when the input contains:

  • A NUL byte (POSIX shells terminate strings at NUL).
  • A newline (single and double quotes preserve the literal; ANSI-C encodes; dash rejects ANSI-C).
  • Control characters other than \n and \t (only ANSI-C encodes these portably).
  • A ! (interactive bash may expand it via history).

What it does not check

  • cmd.exe or PowerShell quoting. Different rules entirely.
  • fish quoting. Fish has its own escape rules; the sibling tool fish-completion-escape covers the completion-source side of that.
  • csh and tcsh quoting. Long deprecated for scripting.
  • Whether the resulting command does what you want. The tool only shows what reaches the shell; the shell still decides what to run.

Why it exists

Building shell one-liners for ssh, xargs -I, find -exec, and container entrypoint overrides keeps surfacing the same question: which quoting form does this string need to survive intact? The answer depends on the input's contents and the target shell. This tool collapses the decision into a single glance.

Tech

One HTML file. Inline CSS and JS. No dependencies, no build, no network calls. Works offline after first load. The quoting functions mirror the rules in POSIX.1-2017 §2.2 and the bash reference manual.

License

MIT.

About

Paste any string. See it quoted four ways for POSIX shells: single, double, ANSI-C, printf %q.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages