From 206787537e448b945257ad52690bc4c5bab1afc5 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Tue, 17 Sep 2019 12:51:55 +0200 Subject: [PATCH] Explicitly unescape hash signs. Required since Nix 2.3. --- rules.nix | 8 ++++++-- tests/testdata.nix | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/rules.nix b/rules.nix index 57746dd..81a04cc 100644 --- a/rules.nix +++ b/rules.nix @@ -105,10 +105,14 @@ rec { in str : recurse str; chars = s: filter (c: c != "" && !isList c) (splitString s); escape = s: map (c: "\\" + c) (chars s); + + # The "#" character normally starts a comment, but can be escaped with a + # backslash to be a literal # in the pattern. + unescapes = "#"; in replaceStrings - ((chars special) ++ (escape escs) ++ ["**/" "**" "*" "?"]) - ((escape special) ++ (escape escs) ++ ["(.*/)?" ".*" "[^/]*" "[^/]"]); + ((chars special) ++ (escape unescapes) ++ (escape escs) ++ ["**/" "**" "*" "?"]) + ((escape special) ++ (chars unescapes) ++ (escape escs) ++ ["(.*/)?" ".*" "[^/]*" "[^/]"]); # (regex -> regex) -> regex -> regex mapAroundCharclass = f: r: # rl = regex or list diff --git a/tests/testdata.nix b/tests/testdata.nix index d26ae7e..2ca02f6 100644 --- a/tests/testdata.nix +++ b/tests/testdata.nix @@ -15,6 +15,8 @@ let create-tree() { ( mkdir -p "$1"; cd "$1" + touch '#' '#ignored' + touches 1-simpl {1,2,3,4,5,^,$,^$,$^,[,[[,],]],]]],ab,bb,\\,\\\\,simple-test} touches 1-simpl/1-simpl {1,2,3,4,5,^,$,^$,$^,[,[[,],]],]]],ab,bb,\\,\\\\,simpletest} touches 1-xxxxx/1-simpl {1,2} @@ -29,6 +31,13 @@ let touches 5-directory {1,2,3,4,5,^,$,^$,$^,[,[[,],]],]]],ab,bb,\\,\\\\} + mkdir 6-hash + touch '6-hash/a' '6-hash/a#0' '6-hash/a\#1' '6-hash/a\\#2' + touch '6-hash/b' '6-hash/b#0' '6-hash/b\#1' '6-hash/b\\#2' + touch '6-hash/c' '6-hash/c#0' '6-hash/c\#1' '6-hash/c\\#2' + touch '6-hash/d' '6-hash/d#0' '6-hash/d\#1' '6-hash/d\\#2' + touch '6-hash/z' '6-hash/z#0' '6-hash/z\#1' '6-hash/z\\#2' + touches 9-expected {unfiltered,filtered-via-aux-{filter,ignore,filepath}} touches 10-subdir-ignoring-itself/foo {foo,bar} @@ -73,6 +82,15 @@ let 4-*/other.html$ 5-*/ + + # A hash sign on a line + # + + 6-hash/a*# + 6-hash/b*\# + 6-hash/c*\\# + 6-hash/d*\\\# + 6-hash/z* ''; ignoresAux = "/9-expected/*filepath\n";