File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,14 @@ function shell_parse(str::AbstractString, interpolate::Bool=true;
7070 isempty (st) && error (" \$ right before end of command" )
7171 stpos, c = popfirst! (st)
7272 isspace (c) && error (" space not allowed right after \$ " )
73- ex, j = Meta. parse (s,stpos,greedy= false )
73+ if SubString (s, stpos: min (stpos+ 3 , ncodeunits (s))) == " var\" "
74+ # Disallow var"#" syntax in cmd interpolations.
75+ # TODO : Allow only identifiers after the $ for consistency with
76+ # string interpolation syntax (see #3150)
77+ ex, j = :var , stpos+ 3
78+ else
79+ ex, j = Meta. parse (s,stpos,greedy= false )
80+ end
7481 last_parse = (stpos: prevind (s, j)) .+ s. offset
7582 update_arg (ex);
7683 s = SubString (s, j)
Original file line number Diff line number Diff line change @@ -461,6 +461,15 @@ let c = setenv(`x`, "A"=>true)
461461 @test_throws ArgumentError ` "$c "`
462462end
463463
464+ # Interaction of cmd parsing with var syntax (#32408)
465+ let var = " x" , vars= " z"
466+ @test ` ls $var ` == Cmd ([" ls" , " x" ])
467+ @test ` ls $vars ` == Cmd ([" ls" , " z" ])
468+ @test ` ls $var "y"` == Cmd ([" ls" , " xy" ])
469+ @test ` ls "'$var '"` == Cmd ([" ls" , " 'x'" ])
470+ @test ` ls $var "y"` == Cmd ([" ls" , " x" , " y" ])
471+ end
472+
464473# equality tests for AndCmds
465474@test Base. AndCmds (` $echocmd abc` , ` $echocmd def` ) == Base. AndCmds (` $echocmd abc` , ` $echocmd def` )
466475@test Base. AndCmds (` $echocmd abc` , ` $echocmd def` ) != Base. AndCmds (` $echocmd abc` , ` $echocmd xyz` )
You can’t perform that action at this time.
0 commit comments