File tree Expand file tree Collapse file tree 2 files changed +9
-14
lines changed
Expand file tree Collapse file tree 2 files changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,8 @@ let search_in_path cmd =
145145
146146(* ** string_of_command_spec{,_with_calls *)
147147let string_of_command_spec_with_calls call_with_tags call_with_target resolve_virtuals spec =
148- let rec aux b spec =
148+ let rec aux spec =
149+ let b = Buffer. create 256 in
149150 let first = ref true in
150151 let put_space () =
151152 if ! first then
@@ -166,21 +167,12 @@ let string_of_command_spec_with_calls call_with_tags call_with_target resolve_vi
166167 else (put_space () ; Printf. bprintf b " <virtual %s>" (Shell. quote_filename_if_needed v))
167168 | S l -> List. iter do_spec l
168169 | T tags -> call_with_tags tags; do_spec (! tag_handler tags)
169- | Quote s ->
170- put_space () ;
171- let buf = Buffer. create 256 in
172- aux buf s;
173- put_filename (Buffer. contents buf)
170+ | Quote s -> put_space () ; put_filename (aux s)
174171 in
175- do_spec spec
172+ do_spec spec;
173+ Buffer. contents b
176174 in
177- let b = Buffer. create 256 in
178- (* The best way to prevent bash from switching to its windows-style
179- * quote-handling is to prepend an empty string before the command name. *)
180- if Sys. win32 then
181- Buffer. add_string b " ''" ;
182- aux b spec;
183- Buffer. contents b
175+ aux spec
184176
185177let string_of_command_spec x = string_of_command_spec_with_calls ignore ignore false x
186178
Original file line number Diff line number Diff line change @@ -327,6 +327,9 @@ let windows_shell = lazy begin
327327end
328328
329329let prepare_command_for_windows cmd =
330+ (* The best way to prevent bash from switching to its windows-style
331+ * quote-handling is to prepend an empty string before the command name. *)
332+ let cmd = " ''" ^ cmd in
330333 Array. append (Lazy. force windows_shell) [|" -c" ; cmd|]
331334
332335let sys_command_win32 cmd =
You can’t perform that action at this time.
0 commit comments