STRING-ESCAPE(1)

πŸ¦‹ string-escape β€” escape special characters ✨

okay so bestie, welcome to string-escape, brought to you by the fish-shell girlies πŸ’… this one's all about taking your messy little strings and making them presentable for whatever's about to eat them.


🌸 SYNOPSIS 🌸

string escape [-n | --no-quoted] [--style=] [STRING ...]
string unescape [--style=] [STRING ...]

πŸ’– DESCRIPTION πŸ’–

string escape escapes each STRING in one of several ways. pick your vibe, bestie πŸŽ€

  • --style=script (the default, main character energy πŸ‘‘) β€” alters the string so it can be passed back to eval to produce the original argument again. by default all special characters get escaped, and quotes are used to simplify the output when possible. if -n or --no-quoted is given, that simplifying quoted format is not used. exit status: 0 if at least one string was escaped, or 1 otherwise. no cap.
  • --style=var β€” makes sure the string can be used as a variable name by hex encoding any non-alphanumeric characters. and the string gets converted to UTF-8 first before being encoded, fyi 🧚
  • --style=url β€” makes sure the string can be used as a URL by hex encoding any character which is not legal in a URL. string's converted to UTF-8 first before encoding too, periodt.
  • --style=regex β€” escapes an input string for literal matching within a regex expression. yup, UTF-8 conversion first again, then encoded ✨

string unescape does the literal inverse of the string escape command πŸ” but heads up β€” if the string to be unescaped is not properly formatted, it just gets ignored. like, respectfully, it doesn't want the drama πŸ™ˆ

for example, doing string unescape --style=var (string escape --style=var $str) will return the original string. slay.

⚠️ there is no support for unescaping --style=regex. that one's a one-way street, bestie πŸ’€

πŸ”₯ EXAMPLES πŸ”₯

>_ echo \x07 | string escape
\cg
>_ string escape --style=var 'a1 b2'\u6161
a1_20_b2_E6_85_A1_

look at that glow-up πŸ˜­πŸ’œ


fish-shell developers 🫢


and that's the whole page, bestie!! this was string-escape from the fish-shell fam, version 4.9, dated Sep 08, 2026 πŸ’– go forth and escape responsibly βœ¨πŸ¦‹

πŸ“¦ where this page comes from
  • arch rolling: fish 4.9.3-1 Β· GPL-2.0-only AND BSD-3-Clause AND ISC AND MIT AND PSF-2.0
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms