···328 escape ["(" ")"] "(foo)"
329 => "\\(foo\\)"
330 */
331- escape = list: replaceChars list (map (c: "\\${c}") list);
332333 /* Escape occurence of the element of `list` in `string` by
334 converting to its ASCII value and prefixing it with \\x.
···341 => "foo\\x20bar"
342343 */
344- escapeC = list: replaceChars list (map (c: "\\x${ toLower (lib.toHexString (charToInt c))}") list);
345346 /* Quote string to be used safely within the Bourne shell.
347···471 ["\"" "'" "<" ">" "&"]
472 [""" "'" "<" ">" "&"];
473474- # Obsolete - use replaceStrings instead.
475- replaceChars = builtins.replaceStrings or (
476- del: new: s:
477- let
478- substList = lib.zipLists del new;
479- subst = c:
480- let found = lib.findFirst (sub: sub.fst == c) null substList; in
481- if found == null then
482- c
483- else
484- found.snd;
485- in
486- stringAsChars subst s);
487488 # Case conversion utilities.
489 lowerChars = stringToCharacters "abcdefghijklmnopqrstuvwxyz";
···497 toLower "HOME"
498 => "home"
499 */
500- toLower = replaceChars upperChars lowerChars;
501502 /* Converts an ASCII string to upper-case.
503···507 toUpper "home"
508 => "HOME"
509 */
510- toUpper = replaceChars lowerChars upperChars;
511512 /* Appends string context from another string. This is an implementation
513 detail of Nix and should be used carefully.
···328 escape ["(" ")"] "(foo)"
329 => "\\(foo\\)"
330 */
331+ escape = list: replaceStrings list (map (c: "\\${c}") list);
332333 /* Escape occurence of the element of `list` in `string` by
334 converting to its ASCII value and prefixing it with \\x.
···341 => "foo\\x20bar"
342343 */
344+ escapeC = list: replaceStrings list (map (c: "\\x${ toLower (lib.toHexString (charToInt c))}") list);
345346 /* Quote string to be used safely within the Bourne shell.
347···471 ["\"" "'" "<" ">" "&"]
472 [""" "'" "<" ">" "&"];
473474+ # warning added 12-12-2022
475+ replaceChars = lib.warn "replaceChars is a deprecated alias of replaceStrings, replace usages of it with replaceStrings." builtins.replaceStrings;
00000000000476477 # Case conversion utilities.
478 lowerChars = stringToCharacters "abcdefghijklmnopqrstuvwxyz";
···486 toLower "HOME"
487 => "home"
488 */
489+ toLower = replaceStrings upperChars lowerChars;
490491 /* Converts an ASCII string to upper-case.
492···496 toUpper "home"
497 => "HOME"
498 */
499+ toUpper = replaceStrings lowerChars upperChars;
500501 /* Appends string context from another string. This is an implementation
502 detail of Nix and should be used carefully.
+3-3
nixos/lib/systemd-lib.nix
···8 systemd = cfg.package;
9in rec {
1011- shellEscape = s: (replaceChars [ "\\" ] [ "\\\\" ] s);
1213- mkPathSafeName = lib.replaceChars ["@" ":" "\\" "[" "]"] ["-" "-" "-" "" ""];
1415 # a type for options that take a unit name
16 unitNameType = types.strMatching "[a-zA-Z0-9@%:_.\\-]+[.](service|socket|device|mount|automount|swap|target|path|timer|scope|slice)";
···258259 makeJobScript = name: text:
260 let
261- scriptName = replaceChars [ "\\" "@" ] [ "-" "_" ] (shellEscape name);
262 out = (pkgs.writeShellScriptBin scriptName ''
263 set -e
264 ${text}
···8 systemd = cfg.package;
9in rec {
1011+ shellEscape = s: (replaceStrings [ "\\" ] [ "\\\\" ] s);
1213+ mkPathSafeName = lib.replaceStrings ["@" ":" "\\" "[" "]"] ["-" "-" "-" "" ""];
1415 # a type for options that take a unit name
16 unitNameType = types.strMatching "[a-zA-Z0-9@%:_.\\-]+[.](service|socket|device|mount|automount|swap|target|path|timer|scope|slice)";
···258259 makeJobScript = name: text:
260 let
261+ scriptName = replaceStrings [ "\\" "@" ] [ "-" "_" ] (shellEscape name);
262 out = (pkgs.writeShellScriptBin scriptName ''
263 set -e
264 ${text}
+3-3
nixos/lib/utils.nix
···48 trim = s: removeSuffix "/" (removePrefix "/" s);
49 normalizedPath = strings.normalizePath s;
50 in
51- replaceChars ["/"] ["-"]
52 (replacePrefix "." (strings.escapeC ["."] ".")
53 (strings.escapeC (stringToCharacters " !\"#$%&'()*+,;<=>=@[\\]^`{|}~-")
54 (if normalizedPath == "/" then normalizedPath else trim normalizedPath)));
···67 else if builtins.isInt arg || builtins.isFloat arg then toString arg
68 else throw "escapeSystemdExecArg only allows strings, paths and numbers";
69 in
70- replaceChars [ "%" "$" ] [ "%%" "$$" ] (builtins.toJSON s);
7172 # Quotes a list of arguments into a single string for use in a Exec*
73 # line.
···112 else if isAttrs item then
113 map (name:
114 let
115- escapedName = ''"${replaceChars [''"'' "\\"] [''\"'' "\\\\"] name}"'';
116 in
117 recurse (prefix + "." + escapedName) item.${name}) (attrNames item)
118 else if isList item then
···48 trim = s: removeSuffix "/" (removePrefix "/" s);
49 normalizedPath = strings.normalizePath s;
50 in
51+ replaceStrings ["/"] ["-"]
52 (replacePrefix "." (strings.escapeC ["."] ".")
53 (strings.escapeC (stringToCharacters " !\"#$%&'()*+,;<=>=@[\\]^`{|}~-")
54 (if normalizedPath == "/" then normalizedPath else trim normalizedPath)));
···67 else if builtins.isInt arg || builtins.isFloat arg then toString arg
68 else throw "escapeSystemdExecArg only allows strings, paths and numbers";
69 in
70+ replaceStrings [ "%" "$" ] [ "%%" "$$" ] (builtins.toJSON s);
7172 # Quotes a list of arguments into a single string for use in a Exec*
73 # line.
···112 else if isAttrs item then
113 map (name:
114 let
115+ escapedName = ''"${replaceStrings [''"'' "\\"] [''\"'' "\\\\"] name}"'';
116 in
117 recurse (prefix + "." + escapedName) item.${name}) (attrNames item)
118 else if isList item then
···53 extraArgs = removeAttrs args ([ "name" "scheme" "xcodeFlags" "release" "certificateFile" "certificatePassword" "provisioningProfile" "signMethod" "generateIPA" "generateXCArchive" "enableWirelessDistribution" "installURL" "bundleId" "version" ] ++ builtins.attrNames xcodewrapperFormalArgs);
54in
55stdenv.mkDerivation ({
56- name = lib.replaceChars [" "] [""] name; # iOS app names can contain spaces, but in the Nix store this is not allowed
57 buildPhase = ''
58 # Be sure that the Xcode wrapper has priority over everything else.
59 # When using buildInputs this does not seem to be the case.
···53 extraArgs = removeAttrs args ([ "name" "scheme" "xcodeFlags" "release" "certificateFile" "certificatePassword" "provisioningProfile" "signMethod" "generateIPA" "generateXCArchive" "enableWirelessDistribution" "installURL" "bundleId" "version" ] ++ builtins.attrNames xcodewrapperFormalArgs);
54in
55stdenv.mkDerivation ({
56+ name = lib.replaceStrings [" "] [""] name; # iOS app names can contain spaces, but in the Nix store this is not allowed
57 buildPhase = ''
58 # Be sure that the Xcode wrapper has priority over everything else.
59 # When using buildInputs this does not seem to be the case.