1717
1818function shell_parse (str:: AbstractString , interpolate:: Bool = true ;
1919 special:: AbstractString = " " )
20- s:: SubString = SubString (str, firstindex (str))
20+ s = SubString (str, firstindex (str))
2121 s = rstrip_shell (lstrip (s))
2222
2323 # N.B.: This is used by REPLCompletions
@@ -37,9 +37,9 @@ function shell_parse(str::AbstractString, interpolate::Bool=true;
3737 push! (arg, x)
3838 end
3939 end
40- function consume_upto (j)
40+ function consume_upto (s, i, j)
4141 update_arg (s[i: prevind (s, j)])
42- i = something (peek (st), (lastindex (s)+ 1 ,' \0 ' ))[1 ]
42+ something (peek (st), (lastindex (s)+ 1 ,' \0 ' ))[1 ]
4343 end
4444 function append_arg ()
4545 if isempty (arg); arg = Any[" " ,]; end
@@ -49,7 +49,7 @@ function shell_parse(str::AbstractString, interpolate::Bool=true;
4949
5050 for (j, c) in st
5151 if ! in_single_quotes && ! in_double_quotes && isspace (c)
52- consume_upto (j)
52+ i = consume_upto (s, i, j)
5353 append_arg ()
5454 while ! isempty (st)
5555 # We've made sure above that we don't end in whitespace,
@@ -59,7 +59,7 @@ function shell_parse(str::AbstractString, interpolate::Bool=true;
5959 popfirst! (st)
6060 end
6161 elseif interpolate && ! in_single_quotes && c == ' $'
62- consume_upto (j)
62+ i = consume_upto (s, i, j)
6363 isempty (st) && error (" \$ right before end of command" )
6464 stpos, c = popfirst! (st)
6565 isspace (c) && error (" space not allowed right after \$ " )
@@ -79,21 +79,21 @@ function shell_parse(str::AbstractString, interpolate::Bool=true;
7979 else
8080 if ! in_double_quotes && c == ' \' '
8181 in_single_quotes = ! in_single_quotes
82- consume_upto (j)
82+ i = consume_upto (s, i, j)
8383 elseif ! in_single_quotes && c == ' "'
8484 in_double_quotes = ! in_double_quotes
85- consume_upto (j)
85+ i = consume_upto (s, i, j)
8686 elseif c == ' \\ '
8787 if in_double_quotes
8888 isempty (st) && error (" unterminated double quote" )
8989 k, c′ = peek (st)
9090 if c′ == ' "' || c′ == ' $' || c′ == ' \\ '
91- consume_upto (j)
91+ i = consume_upto (s, i, j)
9292 _ = popfirst! (st)
9393 end
9494 elseif ! in_single_quotes
9595 isempty (st) && error (" dangling backslash" )
96- consume_upto (j)
96+ i = consume_upto (s, i, j)
9797 _ = popfirst! (st)
9898 end
9999 elseif ! in_single_quotes && ! in_double_quotes && c in special
0 commit comments