Skip to content

Commit

Permalink
Added quoting tests for shell_split.
Browse files Browse the repository at this point in the history
  • Loading branch information
omus committed Sep 14, 2015
1 parent 4d6d33f commit db4caa8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/choosetests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function choosetests(choices = [])
"nullable", "meta", "profile", "libgit2", "docs", "markdown",
"base64", "serialize", "functors", "misc",
"enums", "cmdlineargs", "i18n", "workspace", "libdl", "int",
"intset", "floatfuncs", "compile"
"intset", "floatfuncs", "compile", "shell"
]

if Base.USE_GPL_LIBS
Expand Down
21 changes: 21 additions & 0 deletions test/shell.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This file is a part of Julia. License is MIT: http://julialang.org/license

# Ensure that quoting works
@test Base.shell_split("foo bar baz") == ["foo", "bar", "baz"]
@test Base.shell_split("foo\\ bar baz") == ["foo bar", "baz"]
@test Base.shell_split("'foo bar' baz") == ["foo bar", "baz"]
@test Base.shell_split("\"foo bar\" baz") == ["foo bar", "baz"]

# "Over quoted"
@test Base.shell_split("'foo\\ bar' baz") == ["foo\\ bar", "baz"]
@test Base.shell_split("\"foo\\ bar\" baz") == ["foo\\ bar", "baz"]

# Ensure that split works on ENV["EDITOR"] parsing as used by "edit".
# See #13032.
@test Base.shell_split("Sublime\\ Text/subl -w") == ["Sublime Text/subl", "-w"]
@test Base.shell_split("'Sublime Text/subl' -w") == ["Sublime Text/subl", "-w"]
@test Base.shell_split("\"Sublime Text/subl\" -w") == ["Sublime Text/subl", "-w"]

# Backticks should automatically quote where necessary
cmd = ["foo bar", "baz"]
@test string(`$cmd`) == "`'foo bar' baz`"

0 comments on commit db4caa8

Please sign in to comment.