From 9876c2fe9e90b49f693da628e8b8b696ec5f63a4 Mon Sep 17 00:00:00 2001 From: Someone Serge Date: Sun, 11 Aug 2024 14:42:42 +0000 Subject: [PATCH] stdenv: concatStringsSep: test sep="&" The test fails without 64eaa6318185fe0c3e54b0e4e0f2d5b12ebe34ab ("stdenv: concatStringsSep: quote ${sep}") Co-authored-by: Ivan Trubach Co-authored-by: Wolfgang Walther --- pkgs/test/stdenv/default.nix | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pkgs/test/stdenv/default.nix b/pkgs/test/stdenv/default.nix index a6885d65cea8..a5b571b5a9f4 100644 --- a/pkgs/test/stdenv/default.nix +++ b/pkgs/test/stdenv/default.nix @@ -136,18 +136,21 @@ let { inherit name; + # NOTE: Testing with "&" as separator is intentional, because unquoted + # "&" has a special meaning in the "${var//pattern/replacement}" syntax. + # Cf. https://github.com/NixOS/nixpkgs/pull/318614#discussion_r1706191919 passAsFile = [ "buildCommand" ]; buildCommand = '' declare -A associativeArray=(["X"]="Y") [[ $(concatStringsSep ";" associativeArray 2>&1) =~ "trying to use" ]] || (echo "concatStringsSep did not throw concatenating associativeArray" && false) string="lorem ipsum dolor sit amet" - stringWithSep="$(concatStringsSep ";" string)" - [[ "$stringWithSep" == "lorem;ipsum;dolor;sit;amet" ]] || (echo "'\$stringWithSep' was not 'lorem;ipsum;dolor;sit;amet'" && false) + stringWithSep="$(concatStringsSep "&" string)" + [[ "$stringWithSep" == "lorem&ipsum&dolor&sit&amet" ]] || (echo "'\$stringWithSep' was not 'lorem&ipsum&dolor&sit&amet'" && false) array=("lorem ipsum" "dolor" "sit amet") - arrayWithSep="$(concatStringsSep ";" array)" - [[ "$arrayWithSep" == "lorem ipsum;dolor;sit amet" ]] || (echo "'\$arrayWithSep' was not 'lorem ipsum;dolor;sit amet'" && false) + arrayWithSep="$(concatStringsSep "&" array)" + [[ "$arrayWithSep" == "lorem ipsum&dolor&sit amet" ]] || (echo "'\$arrayWithSep' was not 'lorem ipsum&dolor&sit amet'" && false) touch $out '';