summaryrefslogtreecommitdiff
path: root/src/builtins.zig
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.oliveira1676@etec.sp.gov.br>2025-12-05 06:20:38 +0000
committerLucas Faria Mendes <lucas.oliveira1676@etec.sp.gov.br>2025-12-05 06:20:38 +0000
commitc3c3c2202cf312842230f7316c69a89c28c60ce9 (patch)
treef696534bebecb27005fc609738b4b0cfa3fe1e0b /src/builtins.zig
parent9c60f224204eb2091d64131eba19afcca3bce769 (diff)
downloadshell-zig-c3c3c2202cf312842230f7316c69a89c28c60ce9.tar.gz
shell-zig-c3c3c2202cf312842230f7316c69a89c28c60ce9.zip
codecrafters submit [skip ci]
Diffstat (limited to 'src/builtins.zig')
-rw-r--r--src/builtins.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/builtins.zig b/src/builtins.zig
index 409b57d..2a1eed7 100644
--- a/src/builtins.zig
+++ b/src/builtins.zig
@@ -40,6 +40,15 @@ pub fn executeEcho(stdout: anytype, args: ?[]const u8) !void {
} else if (in_quote and a[i] == quote_char) {
in_quote = false;
last_was_space = false;
+ } else if (in_quote and quote_char == '"' and a[i] == '\\' and i + 1 < a.len) {
+ const next = a[i + 1];
+ if (next == '"' or next == '\\') {
+ i += 1;
+ _ = unquoted.append(std.heap.page_allocator, a[i]) catch {};
+ } else {
+ _ = unquoted.append(std.heap.page_allocator, a[i]) catch {};
+ }
+ last_was_space = false;
} else if (!in_quote and a[i] == ' ') {
if (!last_was_space) {
_ = unquoted.append(std.heap.page_allocator, ' ') catch {};