Multiline strings suggestion. Escaping allows newline to be overwritten and somehow all following lines.
Take
echo "a\" # THIS IS FALSE, but does not break immediately and corrupts later lets
echo "a\"\""
echo "\$"
#echo "a"
#echo "a\\"""
#echo "a\\\" # THIS IS FALSE, but does not break immediately and corrupts later lets
Then the output is
a" # THIS IS FALSE, but does not break immediately and corrupts later lets
echo a""
echo $
#echo a
#echo a\
#echo a\
However the user would likely expect "a\"
to fail.
This does not look very safe to me to allow.
Multiline strings should have a special syntax, since the user likely intends to write only the current line.
My complete test for escaping, which in the let
broke the shell was
echo "a"
echo "a\\"""
echo "a\\\" # THIS IS FALSE, but does not break immediately and corrupts later lets
echo "a\\\\"
echo "a\\\\\" # THIS IS FALSE, but does not break immediately and corrupts later lets
echo "a\\\\\\"
echo "\\t"
echo "t1\tt2"
echo "\\n"
echo "\n"
let fa = FALSE
let ri = RIGHT
let testvar = "\\foobar"
echo "\$fa"
echo "\\$ri"
echo "\$(cmd args...)"
echo "\@(cmd args...)"
echo "\[ hello array \]"
and the expected output (which I ran as single line in another shell):
a"
a""
ion: syntax error: unterminated double quote
a\\
ion: syntax error: unterminated double quote
a\\\
\t
t1\tt2
\n
$fa
\RIGHT
$(cmd args...)
@(cmd args...)
\[ hello array \]