Skip to content

Commit 6d4cb6e

Browse files
authored
Merge pull request #99 from rofinn/rf/cmd-interpolation-fix
Add a specific arg_gen method for AbstractPath
2 parents b968272 + 2cc3e81 commit 6d4cb6e

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "FilePathsBase"
22
uuid = "48062228-2e41-5def-b9a4-89aafe57970f"
33
authors = ["Rory Finnegan"]
4-
version = "0.9.4"
4+
version = "0.9.5"
55

66
[deps]
77
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

src/path.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ function Base.show(io::IO, fp::AbstractPath)
6161
get(io, :compact, false) ? print(io, fp) : print(io, "p\"$fp\"")
6262
end
6363

64+
# Needed for path Cmd interpolation to work correctly.
65+
# If this isn't defined the fact that a path is iterable will result in each segment being
66+
# treated as a separate argument.
67+
Base.arg_gen(fp::AbstractPath) = Base.arg_gen(string(fp))
68+
6469
# Default string constructors for AbstractPath types should fall back to calling `parse`.
6570
(::Type{T})(str::AbstractString) where {T<:AbstractPath} = parse(T, str)
6671

src/test.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ ps = PathSet(; symlink=true)
1515
testsets = [
1616
test_registration,
1717
test_show,
18+
test_cmd,
1819
test_parse,
1920
test_convert,
2021
test_components,
@@ -68,6 +69,7 @@ module TestPaths
6869
test,
6970
test_registration,
7071
test_show,
72+
test_cmd,
7173
test_parse,
7274
test_convert,
7375
test_components,
@@ -200,6 +202,13 @@ module TestPaths
200202
end
201203
end
202204

205+
function test_cmd(ps::PathSet)
206+
@testset "cmd" begin
207+
str = string(ps.root)
208+
@test `echo $str` == `echo $(ps.root)`
209+
end
210+
end
211+
203212
function test_parse(ps::PathSet{P}) where P <: AbstractPath
204213
@testset "parsing" begin
205214
str = string(ps.root)
@@ -895,6 +904,7 @@ module TestPaths
895904
TESTALL = [
896905
test_registration,
897906
test_show,
907+
test_cmd,
898908
test_parse,
899909
test_convert,
900910
test_components,

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ include("testpkg.jl")
2323
testsets = [
2424
test_registration,
2525
test_show,
26+
test_cmd,
2627
test_parse,
2728
test_convert,
2829
test_components,

test/system.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ps = PathSet(; symlink=true)
44
testsets = [
55
test_registration,
66
test_show,
7+
test_cmd,
78
test_parse,
89
test_convert,
910
test_components,

0 commit comments

Comments
 (0)