pathExists: isDir when endswith /.

(cherry picked from commit f8a3893e8d77ce4a6e23719a0b2d88464cb84b9c)
This commit is contained in:
Robert Hensing 2023-09-02 22:47:38 +02:00
parent 9e212344f9
commit 860f64c345
2 changed files with 24 additions and 1 deletions

View file

@ -1528,7 +1528,9 @@ static void prim_pathExists(EvalState & state, const PosIdx pos, Value * * args,
auto path = realisePath(state, pos, arg, { .checkForPureEval = false });
/* SourcePath doesn't know about trailing slash. */
auto mustBeDir = arg.type() == nString && arg.str().ends_with("/");
auto mustBeDir = arg.type() == nString
&& (arg.str().ends_with("/")
|| arg.str().ends_with("/."));
try {
auto checked = state.checkSourcePath(path);

View file

@ -2,6 +2,27 @@ builtins.pathExists (./lib.nix)
&& builtins.pathExists (builtins.toPath ./lib.nix)
&& builtins.pathExists (builtins.toString ./lib.nix)
&& !builtins.pathExists (builtins.toString ./lib.nix + "/")
&& !builtins.pathExists (builtins.toString ./lib.nix + "/.")
# FIXME
# && !builtins.pathExists (builtins.toString ./lib.nix + "/..")
# && !builtins.pathExists (builtins.toString ./lib.nix + "/a/..")
# && !builtins.pathExists (builtins.toString ./lib.nix + "/../lib.nix")
&& !builtins.pathExists (builtins.toString ./lib.nix + "/./")
&& !builtins.pathExists (builtins.toString ./lib.nix + "/./.")
&& builtins.pathExists (builtins.toString ./.. + "/lang/lib.nix")
&& !builtins.pathExists (builtins.toString ./.. + "lang/lib.nix")
&& builtins.pathExists (builtins.toString ./. + "/../lang/lib.nix")
&& builtins.pathExists (builtins.toString ./. + "/../lang/./lib.nix")
&& builtins.pathExists (builtins.toString ./.)
&& builtins.pathExists (builtins.toString ./. + "/")
&& builtins.pathExists (builtins.toString ./. + "/../lang")
&& builtins.pathExists (builtins.toString ./. + "/../lang/")
&& builtins.pathExists (builtins.toString ./. + "/../lang/.")
&& builtins.pathExists (builtins.toString ./. + "/../lang/./")
&& builtins.pathExists (builtins.toString ./. + "/../lang//./")
&& builtins.pathExists (builtins.toString ./. + "/../lang/..")
&& builtins.pathExists (builtins.toString ./. + "/../lang/../")
&& builtins.pathExists (builtins.toString ./. + "/../lang/..//")
&& builtins.pathExists (builtins.toPath (builtins.toString ./lib.nix))
&& !builtins.pathExists (builtins.toPath (builtins.toString ./bla.nix))
&& builtins.pathExists ./lib.nix