You will get a commnad-not-found for a, because it actually tried to run it.
I tried to work this around by implementing the magical POSIX quote:
void CodeGen_Bash::output_escaped_string(const std::string &s) {
stream << "'";
std::ptrdiff_t current, previous = 0;
current = s.find("'");
while (current != std::string::npos) {
stream << s.substr(previous, current - previous) << "'\''";
previous = current + 1;
current = s.find("'", previous);
}
stream << s.substr(previous, current - previous);
stream << "'";
}
...combined with disabling the \ keeping behavior in Parser for quoted strings to handle cases like \$ -> literal $, and not enabling the escape for the ExternCall code path. The problem is it also kills legit backslashes like \n.
I tried changing the backslash handling for the lexer as well, but it is too late in midnight for my brain to come up with a sensible solution. Basically I want the new scan_until to:
discard all backslashes that do escape some token
have backslashes self-escape; that is n backslashes turn into n/2 in the actual string
have the boolean parameter decide how to handle the lone odd slash
1 requires rewriting the lookahead part to resemble something like:
find token match
if found_preliminary
if escape
emit n / 2 [result += std::string(backslashes / 2, '\\');]
n %= 2
else
break away from while
Try:
You will get a commnad-not-found for
a
, because it actually tried to run it.I tried to work this around by implementing the magical POSIX quote:
...combined with disabling the
\
keeping behavior in Parser for quoted strings to handle cases like\$
-> literal$
, and not enabling the escape for the ExternCall code path. The problem is it also kills legit backslashes like\n
.I tried changing the backslash handling for the lexer as well, but it is too late in midnight for my brain to come up with a sensible solution. Basically I want the new scan_until to:
1 requires rewriting the lookahead part to resemble something like:
But I am just too tired to try it.