@@ -246,7 +246,8 @@ mod prepare {
246246 #[ test]
247247 fn multiple_arguments_in_one_line_with_auto_split ( ) {
248248 let cmd = std:: process:: Command :: from (
249- gix_command:: prepare ( "echo first second third" ) . with_shell_allow_manual_argument_splitting ( ) ,
249+ gix_command:: prepare ( "echo first second third" )
250+ . command_may_be_shell_script_allow_manual_argument_splitting ( ) ,
250251 ) ;
251252 assert_eq ! (
252253 format!( "{cmd:?}" ) ,
@@ -267,7 +268,8 @@ mod prepare {
267268
268269 #[ test]
269270 fn single_and_multiple_arguments_as_part_of_command_with_shell ( ) {
270- let cmd = std:: process:: Command :: from ( gix_command:: prepare ( "ls first second third" ) . with_shell ( ) ) ;
271+ let cmd =
272+ std:: process:: Command :: from ( gix_command:: prepare ( "ls first second third" ) . command_may_be_shell_script ( ) ) ;
271273 assert_eq ! (
272274 format!( "{cmd:?}" ) ,
273275 if cfg!( windows) {
@@ -283,7 +285,7 @@ mod prepare {
283285 fn single_and_multiple_arguments_as_part_of_command_with_given_shell ( ) {
284286 let cmd = std:: process:: Command :: from (
285287 gix_command:: prepare ( "ls first second third" )
286- . with_shell ( )
288+ . command_may_be_shell_script ( )
287289 . with_shell_program ( "/somepath/to/bash" ) ,
288290 ) ;
289291 assert_eq ! (
@@ -299,7 +301,11 @@ mod prepare {
299301
300302 #[ test]
301303 fn single_and_complex_arguments_as_part_of_command_with_shell ( ) {
302- let cmd = std:: process:: Command :: from ( gix_command:: prepare ( "ls --foo \" a b\" " ) . arg ( "additional" ) . with_shell ( ) ) ;
304+ let cmd = std:: process:: Command :: from (
305+ gix_command:: prepare ( "ls --foo \" a b\" " )
306+ . arg ( "additional" )
307+ . command_may_be_shell_script ( ) ,
308+ ) ;
303309 assert_eq ! (
304310 format!( "{cmd:?}" ) ,
305311 if cfg!( windows) {
@@ -314,7 +320,7 @@ mod prepare {
314320 #[ test]
315321 fn single_and_complex_arguments_with_auto_split ( ) {
316322 let cmd = std:: process:: Command :: from (
317- gix_command:: prepare ( "ls --foo=\" a b\" " ) . with_shell_allow_manual_argument_splitting ( ) ,
323+ gix_command:: prepare ( "ls --foo=\" a b\" " ) . command_may_be_shell_script_allow_manual_argument_splitting ( ) ,
318324 ) ;
319325 assert_eq ! (
320326 format!( "{cmd:?}" ) ,
@@ -326,15 +332,29 @@ mod prepare {
326332 #[ test]
327333 fn single_and_complex_arguments_without_auto_split ( ) {
328334 let cmd = std:: process:: Command :: from (
329- gix_command:: prepare ( "ls --foo=\" a b\" " ) . with_shell_disallow_manual_argument_splitting ( ) ,
335+ gix_command:: prepare ( "ls --foo=\" a b\" " ) . command_may_be_shell_script_disallow_manual_argument_splitting ( ) ,
330336 ) ;
331337 assert_eq ! ( format!( "{cmd:?}" ) , quoted( & [ SH , "-c" , r#"ls --foo=\"a b\""# , "--" ] ) ) ;
332338 }
333339
340+ #[ test]
341+ fn single_and_simple_arguments_without_auto_split_with_shell ( ) {
342+ let cmd = std:: process:: Command :: from (
343+ gix_command:: prepare ( "ls" )
344+ . arg ( "--foo=a b" )
345+ . command_may_be_shell_script_disallow_manual_argument_splitting ( )
346+ . with_shell ( ) ,
347+ ) ;
348+ assert_eq ! (
349+ format!( "{cmd:?}" ) ,
350+ quoted( & [ SH , "-c" , "ls \\ \" $@\\ \" " , "--" , "--foo=a b" ] )
351+ ) ;
352+ }
353+
334354 #[ test]
335355 fn single_and_complex_arguments_will_not_auto_split_on_special_characters ( ) {
336356 let cmd = std:: process:: Command :: from (
337- gix_command:: prepare ( "ls --foo=~/path" ) . with_shell_allow_manual_argument_splitting ( ) ,
357+ gix_command:: prepare ( "ls --foo=~/path" ) . command_may_be_shell_script_allow_manual_argument_splitting ( ) ,
338358 ) ;
339359 assert_eq ! (
340360 format!( "{cmd:?}" ) ,
@@ -345,7 +365,8 @@ mod prepare {
345365
346366 #[ test]
347367 fn tilde_path_and_multiple_arguments_as_part_of_command_with_shell ( ) {
348- let cmd = std:: process:: Command :: from ( gix_command:: prepare ( "~/bin/exe --foo \" a b\" " ) . with_shell ( ) ) ;
368+ let cmd =
369+ std:: process:: Command :: from ( gix_command:: prepare ( "~/bin/exe --foo \" a b\" " ) . command_may_be_shell_script ( ) ) ;
349370 assert_eq ! (
350371 format!( "{cmd:?}" ) ,
351372 format!( r#""{SH}" "-c" "~/bin/exe --foo \"a b\"" "--""# ) ,
@@ -355,7 +376,11 @@ mod prepare {
355376
356377 #[ test]
357378 fn script_with_dollar_at ( ) {
358- let cmd = std:: process:: Command :: from ( gix_command:: prepare ( "echo \" $@\" >&2" ) . with_shell ( ) . arg ( "store" ) ) ;
379+ let cmd = std:: process:: Command :: from (
380+ gix_command:: prepare ( "echo \" $@\" >&2" )
381+ . command_may_be_shell_script ( )
382+ . arg ( "store" ) ,
383+ ) ;
359384 assert_eq ! (
360385 format!( "{cmd:?}" ) ,
361386 format!( r#""{SH}" "-c" "echo \"$@\" >&2" "--" "store""# ) ,
@@ -374,7 +399,7 @@ mod spawn {
374399 let out = gix_command:: prepare ( "echo $FIRST $SECOND" )
375400 . env ( "FIRST" , "first" )
376401 . env ( "SECOND" , "second" )
377- . with_shell ( )
402+ . command_may_be_shell_script ( )
378403 . spawn ( ) ?
379404 . wait_with_output ( ) ?;
380405 assert_eq ! ( out. stdout. as_bstr( ) , "first second\n " ) ;
@@ -385,12 +410,15 @@ mod spawn {
385410 #[ cfg( unix) ]
386411 fn disallow_shell ( ) -> crate :: Result {
387412 let out = gix_command:: prepare ( "PATH= echo hi" )
388- . with_shell ( )
413+ . command_may_be_shell_script ( )
389414 . spawn ( ) ?
390415 . wait_with_output ( ) ?;
391416 assert_eq ! ( out. stdout. as_bstr( ) , "hi\n " ) ;
392417
393- let mut cmd: std:: process:: Command = gix_command:: prepare ( "echo hi" ) . with_shell ( ) . without_shell ( ) . into ( ) ;
418+ let mut cmd: std:: process:: Command = gix_command:: prepare ( "echo hi" )
419+ . command_may_be_shell_script ( )
420+ . without_shell ( )
421+ . into ( ) ;
394422 assert ! (
395423 cmd. env_remove( "PATH" ) . spawn( ) . is_err( ) ,
396424 "no command named 'echo hi' exists"
@@ -400,9 +428,13 @@ mod spawn {
400428
401429 #[ test]
402430 fn script_with_dollar_at ( ) -> crate :: Result {
403- let out = std:: process:: Command :: from ( gix_command:: prepare ( "echo \" $@\" " ) . with_shell ( ) . arg ( "arg" ) )
404- . spawn ( ) ?
405- . wait_with_output ( ) ?;
431+ let out = std:: process:: Command :: from (
432+ gix_command:: prepare ( "echo \" $@\" " )
433+ . command_may_be_shell_script ( )
434+ . arg ( "arg" ) ,
435+ )
436+ . spawn ( ) ?
437+ . wait_with_output ( ) ?;
406438 assert_eq ! (
407439 out. stdout. to_str_lossy( ) . trim( ) ,
408440 "arg" ,
@@ -433,7 +465,7 @@ mod spawn {
433465 #[ test]
434466 fn command_in_path_with_args ( ) -> crate :: Result {
435467 assert ! ( gix_command:: prepare( if cfg!( unix) { "ls -l" } else { "dir.exe -a" } )
436- . with_shell ( )
468+ . command_may_be_shell_script ( )
437469 . spawn( ) ?
438470 . wait( ) ?
439471 . success( ) ) ;
@@ -442,14 +474,18 @@ mod spawn {
442474
443475 #[ test]
444476 fn sh_shell_specific_script_code ( ) -> crate :: Result {
445- assert ! ( gix_command:: prepare( ":;:;:" ) . with_shell( ) . spawn( ) ?. wait( ) ?. success( ) ) ;
477+ assert ! ( gix_command:: prepare( ":;:;:" )
478+ . command_may_be_shell_script( )
479+ . spawn( ) ?
480+ . wait( ) ?
481+ . success( ) ) ;
446482 Ok ( ( ) )
447483 }
448484
449485 #[ test]
450486 fn sh_shell_specific_script_code_with_single_extra_arg ( ) -> crate :: Result {
451487 let out = gix_command:: prepare ( "printf" )
452- . with_shell ( )
488+ . command_may_be_shell_script ( )
453489 . arg ( "1" )
454490 . spawn ( ) ?
455491 . wait_with_output ( ) ?;
@@ -461,7 +497,7 @@ mod spawn {
461497 #[ test]
462498 fn sh_shell_specific_script_code_with_multiple_extra_args ( ) -> crate :: Result {
463499 let out = gix_command:: prepare ( "printf" )
464- . with_shell ( )
500+ . command_may_be_shell_script ( )
465501 . arg ( "%s" )
466502 . arg ( "arg" )
467503 . spawn ( ) ?
0 commit comments