STRING-UNESCAPE(1)

✨ STRING-UNESCAPE ✨

okay so bestie, real talk β€” this is string-unescape(1) from the fish-shell manuals, and it's the page that handles expand escape sequences. it's two commands in a trench coat: string escape and string unescape, and they're literally inverses of each other. iykyk πŸ’…


🫢 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 flavor, they're all iconic in their own right:

  • --style=script β€” this is the default, and it alters the string so it can be passed back to eval and produce the original argument again. by default, all special characters get escaped, and quotes are used to simplify the output when possible. if you pass -n or --no-quoted, that simplifying quoted format just... isn't used. no cap. Exit status: 0 if at least one string was escaped, or 1 otherwise. simple as that ✨
  • --style=var β€” makes sure the string can be used as a variable name by hex encoding any non-alphanumeric characters. heads up though: the string is first converted to UTF-8 before being encoded. that's the law πŸŽ€
  • --style=url β€” makes the string safe to use as a URL by hex encoding any character which is not legal in a URL. and yes, obsessed, it also converts the string to UTF-8 before being encoded first 🌸
  • --style=regex β€” escapes an input string so it matches literally within a regex expression. you guessed it: the string is first converted to UTF-8 before being encoded πŸ¦‹

now for the other half of the duo: string unescape performs the inverse of the string escape command. but bestie, listen β€” if the string to be unescaped is not properly formatted, it is ignored. no error, no drama, just ignored πŸ™ˆ

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

⚠️ important: there is no support for unescaping --style=regex. sorry regex girlies, it's just not happening πŸ’€

🌈 EXAMPLES 🌈

here's the receipts, fr fr:

>_ echo \x07 | string escape
\cg

>_ string escape --style=var 'a1 b2'\u6161
a1_20_b2_E6_85_A1_

the way that second one just hex-encoded its whole life... main character energy πŸŽ€


fish-shell developers β€” give them their flowers πŸ’


okay that's the whole page!! no gatekeeping here. version 4.9, dated Sep 08, 2026, straight from the fish-shell fam β€” go forth and escape responsibly, bestie πŸ«ΆπŸ’œ

πŸ“¦ 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