Skip to content

Commit

Permalink
shell_parse: deprecate unescaped chars "#{}()[]<>|&*?~;" in commands
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Dec 31, 2016
1 parent 482def8 commit fc61be6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion base/shell.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## shell-like command parsing ##

const shell_special = "#{}()[]<>|&*?~;"

function shell_parse(str::AbstractString, interpolate::Bool=true)
s = lstrip(str)
# strips the end but respects the space when the string ends with "\\ "
Expand Down Expand Up @@ -92,6 +94,8 @@ function shell_parse(str::AbstractString, interpolate::Bool=true)
update_arg(s[i:j-1]); i = k
c, k = next(s,k)
end
elseif !in_single_quotes && !in_double_quotes && c in shell_special
depwarn("special characters \"$shell_special\" should now be quoted in commands", :shell_parse)
end
j = k
end
Expand Down Expand Up @@ -129,7 +133,7 @@ function print_shell_word(io::IO, word::AbstractString)
has_single = false
has_special = false
for c in word
if isspace(c) || c=='\\' || c=='\'' || c=='"' || c=='$'
if isspace(c) || c=='\\' || c=='\'' || c=='"' || c=='$' || c in shell_special
has_special = true
if c == '\''
has_single = true
Expand Down

0 comments on commit fc61be6

Please sign in to comment.