Merge branch 'jk/run-command-notdot'
authorJunio C Hamano <gitster@pobox.com>
Tue, 30 Oct 2018 06:43:41 +0000 (15:43 +0900)
committerJunio C Hamano <gitster@pobox.com>
Tue, 30 Oct 2018 06:43:41 +0000 (15:43 +0900)
The implementation of run_command() API on the UNIX platforms had a
bug that caused a command not on $PATH to be found in the current
directory.

* jk/run-command-notdot:
run-command: mark path lookup errors with ENOENT

1  2 
t/t0061-run-command.sh
diff --combined t/t0061-run-command.sh
index 3e131c5325e363fa6188456e3f5f3f47f762801e,b9cfc03a53d9ef892b047df5a9d6a15fb0febf55..cf932c851411e5abd992005de474cc095abecead
@@@ -11,20 -11,32 +11,31 @@@ cat >hello-script <<-EO
        #!$SHELL_PATH
        cat hello-script
  EOF
 ->empty
  
- test_expect_success 'start_command reports ENOENT' '
+ test_expect_success 'start_command reports ENOENT (slash)' '
        test-tool run-command start-command-ENOENT ./does-not-exist
  '
  
+ test_expect_success 'start_command reports ENOENT (no slash)' '
+       test-tool run-command start-command-ENOENT does-not-exist
+ '
  test_expect_success 'run_command can run a command' '
        cat hello-script >hello.sh &&
        chmod +x hello.sh &&
        test-tool run-command run-command ./hello.sh >actual 2>err &&
  
        test_cmp hello-script actual &&
 -      test_cmp empty err
 +      test_must_be_empty err
  '
  
+ test_expect_success 'run_command is restricted to PATH' '
+       write_script should-not-run <<-\EOF &&
+       echo yikes
+       EOF
+       test_must_fail test-tool run-command run-command should-not-run
+ '
  test_expect_success !MINGW 'run_command can run a script without a #! line' '
        cat >hello <<-\EOF &&
        cat hello-script
@@@ -33,7 -45,7 +44,7 @@@
        test-tool run-command run-command ./hello >actual 2>err &&
  
        test_cmp hello-script actual &&
 -      test_cmp empty err
 +      test_must_be_empty err
  '
  
  test_expect_success 'run_command does not try to execute a directory' '
@@@ -46,7 -58,7 +57,7 @@@
        PATH=$PWD/bin1:$PWD/bin2:$PATH \
                test-tool run-command run-command greet >actual 2>err &&
        test_cmp bin2/greet actual &&
 -      test_cmp empty err
 +      test_must_be_empty err
  '
  
  test_expect_success POSIXPERM 'run_command passes over non-executable file' '
@@@ -63,7 -75,7 +74,7 @@@
        PATH=$PWD/bin1:$PWD/bin2:$PATH \
                test-tool run-command run-command greet >actual 2>err &&
        test_cmp bin2/greet actual &&
 -      test_cmp empty err
 +      test_must_be_empty err
  '
  
  test_expect_success POSIXPERM 'run_command reports EACCES' '