From ad7fa720cabfdf8b64ffa710a453c89eb0689537 Mon Sep 17 00:00:00 2001 From: lens0021 Date: Fri, 15 Nov 2024 00:35:17 +0900 Subject: [PATCH 01/13] Fix typos I am using tekumara/typos-lsp --- src/std/text.ab | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/std/text.ab b/src/std/text.ab index fe071e33..a31a08b3 100644 --- a/src/std/text.ab +++ b/src/std/text.ab @@ -1,14 +1,14 @@ -/// Replaces all occurences of a pattern in the content with the provided replace text. +/// Replaces all occurrences of a pattern in the content with the provided replace text. pub fun replace(source, search, replace) { return "\$\{source//{search}/{replace}}" } -/// Replaces the first occurence of a pattern in the content with the provided replace text. +/// Replaces the first occurrence of a pattern in the content with the provided replace text. pub fun replace_one(source, search, replace) { return "\$\{source/{search}/{replace}}" } -/// Replaces all occurences of a regex pattern in the content with the provided replace text. +/// Replaces all occurrences of a regex pattern in the content with the provided replace text. /// /// Function uses `sed` pub fun replace_regex(source: Text, search: Text, replace: Text, extended: Bool = false): Text { @@ -45,7 +45,7 @@ pub fun split_words(text: Text): [Text] { return split(text, " ") } -/// Merges text using the delimeter specified. +/// Merges text using the delimiter specified. pub fun join(list: [Text], delimiter: Text): Text { return trust $ IFS="{delimiter}" ; echo "\$\{{nameof list}[*]}" $ } From 73c78baacac083795b8d9f19cde10c2939ccbd3a Mon Sep 17 00:00:00 2001 From: lens0021 Date: Fri, 15 Nov 2024 03:02:37 +0900 Subject: [PATCH 02/13] Escape backslashes in search and replacement --- src/std/text.ab | 8 ++++++-- src/tests/stdlib/replace_once.ab | 4 ++++ src/tests/stdlib/text_replace.ab | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 src/tests/stdlib/replace_once.ab diff --git a/src/std/text.ab b/src/std/text.ab index a31a08b3..560977d8 100644 --- a/src/std/text.ab +++ b/src/std/text.ab @@ -1,11 +1,15 @@ /// Replaces all occurrences of a pattern in the content with the provided replace text. pub fun replace(source, search, replace) { - return "\$\{source//{search}/{replace}}" + search = trust $ echo \$\{{nameof search}//\\\\/\\\\\\\\} $ + replace = trust $ echo \$\{{nameof replace}//\\\\/\\\\\\\\} $ + return trust $ echo \$\{{nameof source}//{search}/{replace}} $ } /// Replaces the first occurrence of a pattern in the content with the provided replace text. pub fun replace_one(source, search, replace) { - return "\$\{source/{search}/{replace}}" + search = replace(search, "\\", "\\\\") + replace = replace(replace, "\\", "\\\\") + return trust $ echo \$\{{nameof source}/{search}/{replace}} $ } /// Replaces all occurrences of a regex pattern in the content with the provided replace text. diff --git a/src/tests/stdlib/replace_once.ab b/src/tests/stdlib/replace_once.ab new file mode 100644 index 00000000..e27816c1 --- /dev/null +++ b/src/tests/stdlib/replace_once.ab @@ -0,0 +1,4 @@ +import * from "std/text" +main { + echo replace_once("Succinctly\\", "inctly\\", "eeded") +} diff --git a/src/tests/stdlib/text_replace.ab b/src/tests/stdlib/text_replace.ab index 093bae0f..9ad48966 100644 --- a/src/tests/stdlib/text_replace.ab +++ b/src/tests/stdlib/text_replace.ab @@ -2,7 +2,9 @@ import * from "std/text" // Output // apple apple +// apple main { echo replace("banana banana", "banana", "apple") + echo replace("\\", "\\", "apple") } From 84ad489ce95974c6845b1bd1e3e905bb03a93851 Mon Sep 17 00:00:00 2001 From: lens0021 Date: Fri, 13 Dec 2024 01:25:01 +0900 Subject: [PATCH 03/13] Add Bash <=5.1 compatibility --- src/std/text.ab | 9 ++++++++- src/tests/stdlib/text_replace.ab | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/std/text.ab b/src/std/text.ab index 560977d8..6790407c 100644 --- a/src/std/text.ab +++ b/src/std/text.ab @@ -1,7 +1,14 @@ /// Replaces all occurrences of a pattern in the content with the provided replace text. +#[allow_absurd_cast] pub fun replace(source, search, replace) { search = trust $ echo \$\{{nameof search}//\\\\/\\\\\\\\} $ - replace = trust $ echo \$\{{nameof replace}//\\\\/\\\\\\\\} $ + const bash_major = trust $ echo \"\$\{BASH_VERSINFO[0]}\" $ as Num + const bash_minor = trust $ echo \"\$\{BASH_VERSINFO[1]}\" $ as Num + if bash_major > 5 or (bash_major == 5 and bash_minor > 1) { + replace = trust $ echo \$\{{nameof replace}//\\\\/\\\\\\\\} $ + } else { + replace = trust $ echo \$\{{nameof replace}//\\\\/\\\\} $ + } return trust $ echo \$\{{nameof source}//{search}/{replace}} $ } diff --git a/src/tests/stdlib/text_replace.ab b/src/tests/stdlib/text_replace.ab index 9ad48966..caf9edcf 100644 --- a/src/tests/stdlib/text_replace.ab +++ b/src/tests/stdlib/text_replace.ab @@ -3,8 +3,10 @@ import * from "std/text" // Output // apple apple // apple +// banana\\ main { echo replace("banana banana", "banana", "apple") echo replace("\\", "\\", "apple") + echo replace("banana\\", "\\", "\\\\") } From 046a8faf3c58d615e7fd8526c1624b4fa447e46d Mon Sep 17 00:00:00 2001 From: lens0021 Date: Fri, 13 Dec 2024 01:29:16 +0900 Subject: [PATCH 04/13] docs: Add a TODO --- src/std/text.ab | 1 + 1 file changed, 1 insertion(+) diff --git a/src/std/text.ab b/src/std/text.ab index 6790407c..6d1c52bc 100644 --- a/src/std/text.ab +++ b/src/std/text.ab @@ -2,6 +2,7 @@ #[allow_absurd_cast] pub fun replace(source, search, replace) { search = trust $ echo \$\{{nameof search}//\\\\/\\\\\\\\} $ + // TODO: Revisit after https://github.com/amber-lang/amber/issues/632 const bash_major = trust $ echo \"\$\{BASH_VERSINFO[0]}\" $ as Num const bash_minor = trust $ echo \"\$\{BASH_VERSINFO[1]}\" $ as Num if bash_major > 5 or (bash_major == 5 and bash_minor > 1) { From 4291e535732077799ba0ce6e81a07ad5a144e763 Mon Sep 17 00:00:00 2001 From: Lens0021 / Leslie Date: Tue, 17 Dec 2024 07:13:29 +0900 Subject: [PATCH 05/13] Update src/std/text.ab --- src/std/text.ab | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/std/text.ab b/src/std/text.ab index 6d1c52bc..a5aecb6b 100644 --- a/src/std/text.ab +++ b/src/std/text.ab @@ -2,7 +2,7 @@ #[allow_absurd_cast] pub fun replace(source, search, replace) { search = trust $ echo \$\{{nameof search}//\\\\/\\\\\\\\} $ - // TODO: Revisit after https://github.com/amber-lang/amber/issues/632 + // TODO: Revisit after https://github.com/amber-lang/amber/issues/622 const bash_major = trust $ echo \"\$\{BASH_VERSINFO[0]}\" $ as Num const bash_minor = trust $ echo \"\$\{BASH_VERSINFO[1]}\" $ as Num if bash_major > 5 or (bash_major == 5 and bash_minor > 1) { From 51945cf80410730e0d3fe8ca89ce9cbab336cdf3 Mon Sep 17 00:00:00 2001 From: lens0021 Date: Tue, 17 Dec 2024 07:23:19 +0900 Subject: [PATCH 06/13] Import bash_version() Co-authored-by: Huw Walters --- src/std/text.ab | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/std/text.ab b/src/std/text.ab index a5aecb6b..e4bcd7c6 100644 --- a/src/std/text.ab +++ b/src/std/text.ab @@ -1,11 +1,17 @@ +// Replace this with builtin if/when we get around to writing one. +#[allow_absurd_cast] +fun bash_version(): Num { + let major = trust $ echo "\$\{BASH_VERSINFO[0]}" $ as Num + let minor = trust $ echo "\$\{BASH_VERSINFO[1]}" $ as Num + return (major * 100) + minor +} + /// Replaces all occurrences of a pattern in the content with the provided replace text. #[allow_absurd_cast] pub fun replace(source, search, replace) { search = trust $ echo \$\{{nameof search}//\\\\/\\\\\\\\} $ // TODO: Revisit after https://github.com/amber-lang/amber/issues/622 - const bash_major = trust $ echo \"\$\{BASH_VERSINFO[0]}\" $ as Num - const bash_minor = trust $ echo \"\$\{BASH_VERSINFO[1]}\" $ as Num - if bash_major > 5 or (bash_major == 5 and bash_minor > 1) { + if bash_version() >= 502 { replace = trust $ echo \$\{{nameof replace}//\\\\/\\\\\\\\} $ } else { replace = trust $ echo \$\{{nameof replace}//\\\\/\\\\} $ From e0506c9f86903ead843d0450c232179fa1f0a366 Mon Sep 17 00:00:00 2001 From: lens0021 Date: Tue, 17 Dec 2024 08:13:08 +0900 Subject: [PATCH 07/13] Fix < 5.1 and add tests --- src/std/text.ab | 5 ++++- src/tests/stdlib/replace_once.ab | 8 ++++++++ src/tests/stdlib/text_replace.ab | 8 ++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/std/text.ab b/src/std/text.ab index e4bcd7c6..07060efc 100644 --- a/src/std/text.ab +++ b/src/std/text.ab @@ -22,7 +22,10 @@ pub fun replace(source, search, replace) { /// Replaces the first occurrence of a pattern in the content with the provided replace text. pub fun replace_one(source, search, replace) { search = replace(search, "\\", "\\\\") - replace = replace(replace, "\\", "\\\\") + if bash_version() >= 502 { + replace = replace(replace, "\\", "\\\\") + } + return trust $ echo \$\{{nameof source}/{search}/{replace}} $ } diff --git a/src/tests/stdlib/replace_once.ab b/src/tests/stdlib/replace_once.ab index e27816c1..472e83dd 100644 --- a/src/tests/stdlib/replace_once.ab +++ b/src/tests/stdlib/replace_once.ab @@ -1,4 +1,12 @@ import * from "std/text" + +// Output +// Succeeded +// one\\two\\three\\\. +// one\two\three\\\. + main { echo replace_once("Succinctly\\", "inctly\\", "eeded") + echo replace_once("one\\two\\\\three\\\\\\.", "\\", "\\\\") + echo replace_once("one\\two\\\\three\\\\\\.", "\\\\", "\\") } diff --git a/src/tests/stdlib/text_replace.ab b/src/tests/stdlib/text_replace.ab index caf9edcf..54ea716d 100644 --- a/src/tests/stdlib/text_replace.ab +++ b/src/tests/stdlib/text_replace.ab @@ -3,10 +3,14 @@ import * from "std/text" // Output // apple apple // apple -// banana\\ +// Succeeded +// one\\two\\\\three\\\\\\ +// one\two\three\\ main { echo replace("banana banana", "banana", "apple") echo replace("\\", "\\", "apple") - echo replace("banana\\", "\\", "\\\\") + echo replace("Succinctly\\", "inctly\\", "eeded") + echo replace("one\\two\\\\three\\\\\\", "\\", "\\\\") + echo replace("one\\two\\\\three\\\\\\", "\\\\", "\\") } From a88d03271baae163db2d7dd879bcee6895de7e52 Mon Sep 17 00:00:00 2001 From: lens0021 Date: Tue, 24 Dec 2024 10:33:23 +0900 Subject: [PATCH 08/13] Edit test cases Co-authored-by: Huw Walters --- src/tests/stdlib/replace_once.ab | 14 ++++++++------ src/tests/stdlib/text_replace.ab | 17 ++++++----------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/tests/stdlib/replace_once.ab b/src/tests/stdlib/replace_once.ab index 472e83dd..5b2254d9 100644 --- a/src/tests/stdlib/replace_once.ab +++ b/src/tests/stdlib/replace_once.ab @@ -1,12 +1,14 @@ import * from "std/text" // Output -// Succeeded -// one\\two\\three\\\. -// one\two\three\\\. +// TWO one one +// a\\b\c\d +// first..second +// third +// fourth main { - echo replace_once("Succinctly\\", "inctly\\", "eeded") - echo replace_once("one\\two\\\\three\\\\\\.", "\\", "\\\\") - echo replace_once("one\\two\\\\three\\\\\\.", "\\\\", "\\") + echo replace_once("one one one", "one", "TWO") + echo replace_once("a\\b\\c\\d", "\\", "\\\\") + echo replace_once("first\nsecond\nthird\nfourth", "\n", "..") } diff --git a/src/tests/stdlib/text_replace.ab b/src/tests/stdlib/text_replace.ab index 54ea716d..702aef86 100644 --- a/src/tests/stdlib/text_replace.ab +++ b/src/tests/stdlib/text_replace.ab @@ -1,16 +1,11 @@ import * from "std/text" // Output -// apple apple -// apple -// Succeeded -// one\\two\\\\three\\\\\\ -// one\two\three\\ - +// TWO TWO TWO +// a\\b\\c\\d +// first..second..third..fourth main { - echo replace("banana banana", "banana", "apple") - echo replace("\\", "\\", "apple") - echo replace("Succinctly\\", "inctly\\", "eeded") - echo replace("one\\two\\\\three\\\\\\", "\\", "\\\\") - echo replace("one\\two\\\\three\\\\\\", "\\\\", "\\") + echo replace("one one one", "one", "TWO") + echo replace("a\\b\\c\\d", "\\", "\\\\") + echo replace("first\nsecond\nthird\nfourth", "\n", "..") } From 559a7d0a49151661d9b51014e3bafec9489aff5a Mon Sep 17 00:00:00 2001 From: lens0021 Date: Tue, 24 Dec 2024 10:33:45 +0900 Subject: [PATCH 09/13] Remove old codes --- src/std/text.ab | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/std/text.ab b/src/std/text.ab index 07060efc..49b908d2 100644 --- a/src/std/text.ab +++ b/src/std/text.ab @@ -7,10 +7,8 @@ fun bash_version(): Num { } /// Replaces all occurrences of a pattern in the content with the provided replace text. -#[allow_absurd_cast] pub fun replace(source, search, replace) { search = trust $ echo \$\{{nameof search}//\\\\/\\\\\\\\} $ - // TODO: Revisit after https://github.com/amber-lang/amber/issues/622 if bash_version() >= 502 { replace = trust $ echo \$\{{nameof replace}//\\\\/\\\\\\\\} $ } else { From e226da0ccbec3a771fd635cbc4018d1f883f0157 Mon Sep 17 00:00:00 2001 From: lens0021 Date: Tue, 24 Dec 2024 20:52:37 +0900 Subject: [PATCH 10/13] Use bash command when assigning valuables --- src/std/text.ab | 17 ++++++++++------- src/tests/stdlib/replace_once.ab | 5 +++++ src/tests/stdlib/text_replace.ab | 5 +++++ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/std/text.ab b/src/std/text.ab index 49b908d2..1d79401c 100644 --- a/src/std/text.ab +++ b/src/std/text.ab @@ -8,23 +8,26 @@ fun bash_version(): Num { /// Replaces all occurrences of a pattern in the content with the provided replace text. pub fun replace(source, search, replace) { - search = trust $ echo \$\{{nameof search}//\\\\/\\\\\\\\} $ + // Here we use commands for assigning values to avoid the side effect of Amber + // Escape `\` as `\\`. + trust $ {nameof search}="\$\{{nameof search}//\\\\/\\\\\\\}" $ if bash_version() >= 502 { - replace = trust $ echo \$\{{nameof replace}//\\\\/\\\\\\\\} $ + trust $ {nameof replace}="\$\{{nameof replace}//\\\\/\\\\\\\\}" $ } else { - replace = trust $ echo \$\{{nameof replace}//\\\\/\\\\} $ + trust $ {nameof replace}="\$\{{nameof replace}//\\\\/\\\\}" $ } - return trust $ echo \$\{{nameof source}//{search}/{replace}} $ + return trust $ echo "\$\{{nameof source}//{search}/{replace}}" $ } /// Replaces the first occurrence of a pattern in the content with the provided replace text. pub fun replace_one(source, search, replace) { - search = replace(search, "\\", "\\\\") + // Here we use commands for assigning values to avoid the side effect of Amber + trust $ {nameof search}="\$\{{nameof search}//\\\\/\\\\\\\}" $ if bash_version() >= 502 { - replace = replace(replace, "\\", "\\\\") + trust $ {nameof replace}="\$\{{nameof replace}//\\\\/\\\\\\\\}" $ } - return trust $ echo \$\{{nameof source}/{search}/{replace}} $ + return trust $ echo "\$\{{nameof source}/{search}/{replace}}" $ } /// Replaces all occurrences of a regex pattern in the content with the provided replace text. diff --git a/src/tests/stdlib/replace_once.ab b/src/tests/stdlib/replace_once.ab index 5b2254d9..66821b5c 100644 --- a/src/tests/stdlib/replace_once.ab +++ b/src/tests/stdlib/replace_once.ab @@ -6,9 +6,14 @@ import * from "std/text" // first..second // third // fourth +// mono +// di +// tri main { echo replace_once("one one one", "one", "TWO") echo replace_once("a\\b\\c\\d", "\\", "\\\\") echo replace_once("first\nsecond\nthird\nfourth", "\n", "..") + // other newlines should not be touched + echo replace_once("mono\ndo\ntri", "do\n", "di\n") } diff --git a/src/tests/stdlib/text_replace.ab b/src/tests/stdlib/text_replace.ab index 702aef86..94b2a957 100644 --- a/src/tests/stdlib/text_replace.ab +++ b/src/tests/stdlib/text_replace.ab @@ -4,8 +4,13 @@ import * from "std/text" // TWO TWO TWO // a\\b\\c\\d // first..second..third..fourth +// mono +// di +// tri main { echo replace("one one one", "one", "TWO") echo replace("a\\b\\c\\d", "\\", "\\\\") echo replace("first\nsecond\nthird\nfourth", "\n", "..") + // other newlines should not be touched + echo replace("mono\ndo\ntri", "do\n", "di\n") } From 647a432240f933deec4082117f419b305fadba00 Mon Sep 17 00:00:00 2001 From: lens0021 Date: Tue, 24 Dec 2024 20:57:42 +0900 Subject: [PATCH 11/13] Merge a conflict about test files --- src/tests/stdlib/replace_once.ab | 19 ------------------- src/tests/stdlib/text_replace_one.ab | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 20 deletions(-) delete mode 100644 src/tests/stdlib/replace_once.ab diff --git a/src/tests/stdlib/replace_once.ab b/src/tests/stdlib/replace_once.ab deleted file mode 100644 index 66821b5c..00000000 --- a/src/tests/stdlib/replace_once.ab +++ /dev/null @@ -1,19 +0,0 @@ -import * from "std/text" - -// Output -// TWO one one -// a\\b\c\d -// first..second -// third -// fourth -// mono -// di -// tri - -main { - echo replace_once("one one one", "one", "TWO") - echo replace_once("a\\b\\c\\d", "\\", "\\\\") - echo replace_once("first\nsecond\nthird\nfourth", "\n", "..") - // other newlines should not be touched - echo replace_once("mono\ndo\ntri", "do\n", "di\n") -} diff --git a/src/tests/stdlib/text_replace_one.ab b/src/tests/stdlib/text_replace_one.ab index e1cc16ba..54f0e4b6 100644 --- a/src/tests/stdlib/text_replace_one.ab +++ b/src/tests/stdlib/text_replace_one.ab @@ -1,5 +1,19 @@ import * from "std/text" +// Output +// TWO one one +// a\\b\c\d +// first..second +// third +// fourth +// mono +// di +// tri + main { - echo replace_one("Succinctly", "inctly", "eeded") + echo replace_one("one one one", "one", "TWO") + echo replace_one("a\\b\\c\\d", "\\", "\\\\") + echo replace_one("first\nsecond\nthird\nfourth", "\n", "..") + // other newlines should not be touched + echo replace_one("mono\ndo\ntri", "do\n", "di\n") } From c979ae1f49fb9aefb9ec94a8ba9bcfcddd614b74 Mon Sep 17 00:00:00 2001 From: lens0021 Date: Wed, 25 Dec 2024 03:20:03 +0900 Subject: [PATCH 12/13] misc: Apply reviews --- src/std/text.ab | 3 +-- src/tests/stdlib/text_replace.ab | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/std/text.ab b/src/std/text.ab index 1d79401c..b93c0c37 100644 --- a/src/std/text.ab +++ b/src/std/text.ab @@ -13,9 +13,8 @@ pub fun replace(source, search, replace) { trust $ {nameof search}="\$\{{nameof search}//\\\\/\\\\\\\}" $ if bash_version() >= 502 { trust $ {nameof replace}="\$\{{nameof replace}//\\\\/\\\\\\\\}" $ - } else { - trust $ {nameof replace}="\$\{{nameof replace}//\\\\/\\\\}" $ } + return trust $ echo "\$\{{nameof source}//{search}/{replace}}" $ } diff --git a/src/tests/stdlib/text_replace.ab b/src/tests/stdlib/text_replace.ab index 94b2a957..5a49ea19 100644 --- a/src/tests/stdlib/text_replace.ab +++ b/src/tests/stdlib/text_replace.ab @@ -7,6 +7,7 @@ import * from "std/text" // mono // di // tri + main { echo replace("one one one", "one", "TWO") echo replace("a\\b\\c\\d", "\\", "\\\\") From 4878ce5e69b82fa6a74bab2d5c373201dff339a3 Mon Sep 17 00:00:00 2001 From: lens0021 Date: Wed, 25 Dec 2024 03:45:37 +0900 Subject: [PATCH 13/13] Replace text interpolation with use of nameof --- src/std/text.ab | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/src/std/text.ab b/src/std/text.ab index b93c0c37..d62d83c7 100644 --- a/src/std/text.ab +++ b/src/std/text.ab @@ -1,32 +1,17 @@ -// Replace this with builtin if/when we get around to writing one. -#[allow_absurd_cast] -fun bash_version(): Num { - let major = trust $ echo "\$\{BASH_VERSINFO[0]}" $ as Num - let minor = trust $ echo "\$\{BASH_VERSINFO[1]}" $ as Num - return (major * 100) + minor -} - /// Replaces all occurrences of a pattern in the content with the provided replace text. pub fun replace(source, search, replace) { - // Here we use commands for assigning values to avoid the side effect of Amber - // Escape `\` as `\\`. - trust $ {nameof search}="\$\{{nameof search}//\\\\/\\\\\\\}" $ - if bash_version() >= 502 { - trust $ {nameof replace}="\$\{{nameof replace}//\\\\/\\\\\\\\}" $ - } - - return trust $ echo "\$\{{nameof source}//{search}/{replace}}" $ + // Here we use a command to avoid GH-646 + let result = "" + trust $ {nameof result}="\$\{{nameof source}//\"\$\{{nameof search}}\"/\"\$\{{nameof replace}}\"}" $ + return result } /// Replaces the first occurrence of a pattern in the content with the provided replace text. pub fun replace_one(source, search, replace) { - // Here we use commands for assigning values to avoid the side effect of Amber - trust $ {nameof search}="\$\{{nameof search}//\\\\/\\\\\\\}" $ - if bash_version() >= 502 { - trust $ {nameof replace}="\$\{{nameof replace}//\\\\/\\\\\\\\}" $ - } - - return trust $ echo "\$\{{nameof source}/{search}/{replace}}" $ + // Here we use a command to avoid GH-646 + let result = "" + trust $ {nameof result}="\$\{{nameof source}/\"\$\{{nameof search}}\"/\"\$\{{nameof replace}}\"}" $ + return result } /// Replaces all occurrences of a regex pattern in the content with the provided replace text.