From 81630e7453b869563c9324ad2fe0a02e591dd51a Mon Sep 17 00:00:00 2001 From: Phoenix Himself Date: Thu, 14 Nov 2024 19:37:48 +0100 Subject: [PATCH] fix: bad string escaping --- src/modules/expression/literal/mod.rs | 3 +++ src/std/env.ab | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/expression/literal/mod.rs b/src/modules/expression/literal/mod.rs index c023927a..321e602b 100644 --- a/src/modules/expression/literal/mod.rs +++ b/src/modules/expression/literal/mod.rs @@ -162,6 +162,9 @@ fn translate_escaped_string(string: String, is_str: bool) -> String { chars.next(); }, Some('$') => { + if is_str { + result.push('\\'); + } result.push('$'); chars.next(); }, diff --git a/src/std/env.ab b/src/std/env.ab index 55db8250..d955eec9 100644 --- a/src/std/env.ab +++ b/src/std/env.ab @@ -65,7 +65,7 @@ pub fun is_command(command: Text): Bool { /// Creates a prompt and returns the value. pub fun input(prompt: Text): Text { trust $ read -p "\${nameof prompt}" $ - return "\$REPLY" + return trust $ echo \$REPLY $ } /// Creates a prompt, hides any user input and returns the value. @@ -73,8 +73,8 @@ pub fun input_hidden(prompt: Text): Text { trust { $ read -s -p "\${nameof prompt}" $ $ echo "" >&2 $ + return $ echo \$REPLY $ } - return "\$REPLY" } /// Creates a confirm prompt (Yes/No), and returns true if the choice is Yes.