@@ -49,22 +49,24 @@ function shell_parse(str::AbstractString, interpolate::Bool=true;
4949 empty! (innerlist)
5050 end
5151
52+ C = eltype (str)
53+ P = Pair{Int,C}
5254 for (j, c) in st
53- j, c = j:: Int , c:: eltype (str)
55+ j, c = j:: Int , c:: C
5456 if ! in_single_quotes && ! in_double_quotes && isspace (c)
5557 i = consume_upto! (arg, s, i, j)
5658 append_2to1! (args, arg)
5759 while ! isempty (st)
5860 # We've made sure above that we don't end in whitespace,
5961 # so updating `i` here is ok
60- (i, c) = peek (st):: Pair{Int,eltype(str)}
62+ (i, c) = peek (st):: P
6163 isspace (c) || break
6264 popfirst! (st)
6365 end
6466 elseif interpolate && ! in_single_quotes && c == ' $'
6567 i = consume_upto! (arg, s, i, j)
6668 isempty (st) && error (" \$ right before end of command" )
67- stpos, c = popfirst! (st):: Pair{Int,eltype(str)}
69+ stpos, c = popfirst! (st):: P
6870 isspace (c) && error (" space not allowed right after \$ " )
6971 if startswith (SubString (s, stpos), " var\" " )
7072 # Disallow var"#" syntax in cmd interpolations.
@@ -88,19 +90,19 @@ function shell_parse(str::AbstractString, interpolate::Bool=true;
8890 in_double_quotes = ! in_double_quotes
8991 i = consume_upto! (arg, s, i, j)
9092 elseif ! in_single_quotes && c == ' \\ '
91- if ! isempty (st) && peek (st)[2 ] in (' \n ' , ' \r ' )
93+ if ! isempty (st) && ( peek (st) :: P )[2 ] in (' \n ' , ' \r ' )
9294 i = consume_upto! (arg, s, i, j) + 1
93- if popfirst! (st)[2 ] == ' \r ' && peek (st)[2 ] == ' \n '
95+ if popfirst! (st)[2 ] == ' \r ' && ( peek (st) :: P )[2 ] == ' \n '
9496 i += 1
9597 popfirst! (st)
9698 end
97- while ! isempty (st) && peek (st)[2 ] in (' ' , ' \t ' )
99+ while ! isempty (st) && ( peek (st) :: P )[2 ] in (' ' , ' \t ' )
98100 i = nextind (str, i)
99101 _ = popfirst! (st)
100102 end
101103 elseif in_double_quotes
102104 isempty (st) && error (" unterminated double quote" )
103- k, c′ = peek (st)
105+ k, c′ = peek (st):: P
104106 if c′ == ' "' || c′ == ' $' || c′ == ' \\ '
105107 i = consume_upto! (arg, s, i, j)
106108 _ = popfirst! (st)
0 commit comments