-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previous to this fix, if `dir` was passed as a string instead of a path literal, then the isolation mechanisms provided by the implicit copy behavior of a path in string interpolation was broken, and modules could see the files in their directory. Now both cases are treated identically and isolation is preserved. `strToPath` takes a path like string and converts it back to a path literal to accomplish this.
- Loading branch information
Showing
5 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
pub_fix = mod.fix; | ||
pub_file = mod.file; | ||
pub_set = mod.set; | ||
pub_path = mod.path; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ pub_strToPath = mod.strToPath; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
str: | ||
let | ||
# strip off the first `/` of an absolute path | ||
frag = std.substring 1 (-1) str; | ||
# will fail if the string does not represent an absolute path | ||
# which is what we want since this function makes little sense otherwise | ||
validate = std.toPath str; | ||
# recombine the fragment string with an absolute path starting at the root | ||
# the result with be a path literal instead of a string | ||
path = /. + frag; | ||
in | ||
# avoid the extra work if it is already a path literal | ||
if std.isPath str then str else std.seq validate path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
let | ||
mod = import ../. { } ./bld; | ||
mod = | ||
import ../. { } | ||
# added to test implicit path conversion when path is a string | ||
(builtins.toPath ./bld); | ||
in | ||
builtins.deepSeq mod mod |