Clean up command substitution escapes

This commit is contained in:
Sami Samhuri 2026-02-02 21:13:31 -08:00
parent d6ded9dd46
commit a1410cb5da
No known key found for this signature in database

View file

@ -177,11 +177,7 @@ module Shell
if i + 1 < line.length
escaped = line[i + 1]
if escaped == "$" || escaped == "`" || escaped == "\\" || escaped == "\""
output << (if escaped == "$"
ESCAPED_DOLLAR
else
((escaped == "`") ? ESCAPED_BACKTICK : escaped)
end)
output << escaped_replacement(escaped)
else
output << "\\"
output << escaped
@ -272,6 +268,17 @@ module Shell
stdout.tr("\n", " ")
end
def escaped_replacement(char)
case char
when "$"
ESCAPED_DOLLAR
when "`"
ESCAPED_BACKTICK
else
char
end
end
def protect_escaped_dollars(line)
output = +""
i = 0