hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit f9fc2fc7cdb2e4fe8afb55a856dfe014fe4be0e1
parent 82661f07033c91bda1892cb59313396a40f86dfc
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Wed, 11 May 2022 13:36:00 +0000

shlex::quote: fix handling of backslashes

Signed-off-by: Eyal Sawady <ecs@d2evs.net>

Diffstat:
Mshlex/+test.ha | 1+
Mshlex/escape.ha | 2++
2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/shlex/+test.ha b/shlex/+test.ha @@ -75,4 +75,5 @@ fn testquote(sink: *strio::stream, s: str, expected: str) void = { testquote(&sink, `hello`, `hello`); testquote(&sink, `hello world`, `"hello world"`); testquote(&sink, `'hello' "world"`, `"'hello' "'"'"world"'"'""`); + testquote(&sink, `hello\world`, `"hello\\world"`); }; diff --git a/shlex/escape.ha b/shlex/escape.ha @@ -49,6 +49,8 @@ export fn quote(sink: io::handle, s: str) (size | io::error) = { if (rn == '"') { z += io::writeall(sink, strings::toutf8(`"'"'"`))?; + } else if (rn == '\\') { + z += io::writeall(sink, strings::toutf8(`\\`))?; } else { z += io::writeall(sink, utf8::encoderune(rn))?; };