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