@@ -572,6 +572,47 @@ describe Process do
572572 end
573573 end
574574 end
575+
576+ context " with shell: true" do
577+ it " errors with nonexist $PATH" do
578+ pending! unless {{ flag?(:unix ) }}
579+ Process .run(* print_env_command, shell: true , env: {" PATH" => " /does/not/exist" }).success?.should be_false
580+ end
581+
582+ it " empty path entry means current directory" do
583+ pending! unless {{ flag?(:unix ) }}
584+
585+ with_tempfile(" crystal-spec-run" ) do |dir |
586+ Dir .mkdir dir
587+ File .write(Path [dir, " foo" ], " #!/bin/sh\n echo bar" )
588+ File .chmod(Path [dir, " foo" ], 0o555 )
589+ Process .run(" foo" , chdir: dir, shell: true , env: {" PATH" => " :" }).success?.should be_true
590+ Process .run(" foo" , chdir: dir, shell: true , env: {" PATH" => " ::" }).success?.should be_true
591+ Process .run(" foo" , chdir: dir, shell: true , env: {" PATH" => " /does/not/exist:" }).success?.should be_true
592+ Process .run(" foo" , chdir: dir, shell: true , env: {" PATH" => " :/does/not/exist" }).success?.should be_true
593+ end
594+ end
595+
596+ it " finds path in relative directory" do
597+ pending! unless {{ flag?(:unix ) }}
598+
599+ with_tempfile(" crystal-spec-run" ) do |dir |
600+ Dir .mkdir_p Path [dir, " bin" ]
601+ Dir .mkdir_p Path [dir, " empty" ]
602+ File .write(Path [dir, " bin" , " foo" ], " #!/bin/sh\n echo bar" )
603+ File .chmod(Path [dir, " bin" , " foo" ], 0o555 )
604+ Process .run(" foo" , chdir: dir, shell: true , env: {" PATH" => " bin" }).success?.should be_true
605+ Process .run(" foo" , chdir: dir, shell: true , env: {" PATH" => " empty:bin" }).success?.should be_true
606+ Process .run(" foo" , chdir: dir, shell: true , env: {" PATH" => " bin:empty" }).success?.should be_true
607+ Process .run(" foo" , chdir: dir, shell: true , env: {" PATH" => " /does/not/exist:bin" }).success?.should be_true
608+ Process .run(" foo" , chdir: dir, shell: true , env: {" PATH" => " bin:/does/not/exist" }).success?.should be_true
609+ Process .run(" foo" , chdir: dir, shell: true , env: {" PATH" => " :bin" }).success?.should be_true
610+ Process .run(" foo" , chdir: dir, shell: true , env: {" PATH" => " ::bin" }).success?.should be_true
611+ Process .run(" foo" , chdir: dir, shell: true , env: {" PATH" => " /does/not/exist::bin" }).success?.should be_true
612+ Process .run(" foo" , chdir: dir, shell: true , env: {" PATH" => " bin:/does/not/exist" }).success?.should be_true
613+ end
614+ end
615+ end
575616 end
576617
577618 it " can link processes together" do
0 commit comments