Skip to content

Commit fb1fa13

Browse files
shell_parse: deprecate unescaped chars "#{}()[]<>|&*?~;" in commands
1 parent 94c5fa6 commit fb1fa13

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

base/shell.jl

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## shell-like command parsing ##
44

5+
const shell_special = "#{}()[]<>|&*?~;"
6+
57
function shell_parse(str::AbstractString, interpolate::Bool=true)
68
s = lstrip(str)
79
# strips the end but respects the space when the string ends with "\\ "
@@ -92,6 +94,8 @@ function shell_parse(str::AbstractString, interpolate::Bool=true)
9294
update_arg(s[i:j-1]); i = k
9395
c, k = next(s,k)
9496
end
97+
elseif !in_single_quotes && !in_double_quotes && c in shell_special
98+
depwarn("special characters \"$shell_special\" should now be quoted in commands", :shell_parse)
9599
end
96100
j = k
97101
end
@@ -129,7 +133,7 @@ function print_shell_word(io::IO, word::AbstractString)
129133
has_single = false
130134
has_special = false
131135
for c in word
132-
if isspace(c) || c=='\\' || c=='\'' || c=='"' || c=='$'
136+
if isspace(c) || c=='\\' || c=='\'' || c=='"' || c=='$' || c in shell_special
133137
has_special = true
134138
if c == '\''
135139
has_single = true

0 commit comments

Comments
 (0)