diff --git a/stdlib/std.jsonnet b/stdlib/std.jsonnet index b2780cd54..fccbe26d5 100644 --- a/stdlib/std.jsonnet +++ b/stdlib/std.jsonnet @@ -1018,21 +1018,11 @@ limitations under the License. escapeStringBash(str_):: local str = std.toString(str_); - local trans(ch) = - if ch == "'" then - "'\"'\"'" - else - ch; - "'%s'" % std.join('', [trans(ch) for ch in std.stringChars(str)]), + "'%s'" % std.strReplace(str, "'", "'\"'\"'"), escapeStringDollars(str_):: local str = std.toString(str_); - local trans(ch) = - if ch == '$' then - '$$' - else - ch; - std.foldl(function(a, b) a + trans(b), std.stringChars(str), ''), + std.strReplace(str, '$', '$$'), local xml_escapes = { '<': '<',