From 05a2dfd6744cdc6ab0b57f8ab866cc686b05f519 Mon Sep 17 00:00:00 2001 From: Artturin Date: Mon, 12 Dec 2022 03:36:03 +0200 Subject: lib.replaceChars: warn about being a deprecated alias replaceStrings has been in nix since 2015(nix 1.10) so it is safe to remove the fallback https://github.com/nixos/nix/commit/d6d5885c1567454754a0d260521bafa0bd5e7fdb --- lib/strings.nix | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'lib/strings.nix') diff --git a/lib/strings.nix b/lib/strings.nix index 376c537287e94..64bf5bbafd3da 100644 --- a/lib/strings.nix +++ b/lib/strings.nix @@ -328,7 +328,7 @@ rec { escape ["(" ")"] "(foo)" => "\\(foo\\)" */ - escape = list: replaceChars list (map (c: "\\${c}") list); + escape = list: replaceStrings list (map (c: "\\${c}") list); /* Escape occurence of the element of `list` in `string` by converting to its ASCII value and prefixing it with \\x. @@ -341,7 +341,7 @@ rec { => "foo\\x20bar" */ - escapeC = list: replaceChars list (map (c: "\\x${ toLower (lib.toHexString (charToInt c))}") list); + escapeC = list: replaceStrings list (map (c: "\\x${ toLower (lib.toHexString (charToInt c))}") list); /* Quote string to be used safely within the Bourne shell. @@ -471,19 +471,8 @@ rec { ["\"" "'" "<" ">" "&"] [""" "'" "<" ">" "&"]; - # Obsolete - use replaceStrings instead. - replaceChars = builtins.replaceStrings or ( - del: new: s: - let - substList = lib.zipLists del new; - subst = c: - let found = lib.findFirst (sub: sub.fst == c) null substList; in - if found == null then - c - else - found.snd; - in - stringAsChars subst s); + # warning added 12-12-2022 + replaceChars = lib.warn "replaceChars is a deprecated alias of replaceStrings, replace usages of it with replaceStrings." builtins.replaceStrings; # Case conversion utilities. lowerChars = stringToCharacters "abcdefghijklmnopqrstuvwxyz"; @@ -497,7 +486,7 @@ rec { toLower "HOME" => "home" */ - toLower = replaceChars upperChars lowerChars; + toLower = replaceStrings upperChars lowerChars; /* Converts an ASCII string to upper-case. @@ -507,7 +496,7 @@ rec { toUpper "home" => "HOME" */ - toUpper = replaceChars lowerChars upperChars; + toUpper = replaceStrings lowerChars upperChars; /* Appends string context from another string. This is an implementation detail of Nix and should be used carefully. -- cgit 1.4.1