diff --git a/.gitignore b/.gitignore index 270ed56ecf690d00db5abf8b4d91f3c72eb018e5..f7bdf0f81f09ff8bda463546108a49b9888aa40e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,35 +1,36 @@ -# Ignore default build directories -darwin-[234] -darwin-8bit-[234] -linux-[234] -linux-8bit-[234] -sparc-[234] -sparc-8bit-[234] -build-* -# Ignore emacs files -*~ + +# Ignore default build directories +# Ignore emacs files # Ignore fasls +# Ignore files generated by TeX *.fasl -*.sse2f -*.x86f *.ppcf *.sparcf - -# Ignore files generated by TeX +*.sse2f +*.x86f +*~ +/test-tmp +build-* +darwin-8bit-[234] +darwin-[234] +linux-8bit-[234] +linux-[234] +sparc-8bit-[234] +sparc-[234] src/docs/cmu-user/*.aux src/docs/cmu-user/*.cdx src/docs/cmu-user/*.cnd src/docs/cmu-user/*.fdx src/docs/cmu-user/*.fnd src/docs/cmu-user/*.idx +src/docs/cmu-user/*.ilg +src/docs/cmu-user/*.log +src/docs/cmu-user/*.out +src/docs/cmu-user/*.pdf src/docs/cmu-user/*.tdx src/docs/cmu-user/*.tnd src/docs/cmu-user/*.toc src/docs/cmu-user/*.vdx src/docs/cmu-user/*.vnd -src/docs/cmu-user/*.ilg -src/docs/cmu-user/*.out -src/docs/cmu-user/*.pdf -src/docs/cmu-user/*.log diff --git a/bin/run-tests.sh b/bin/run-tests.sh index 42f9ec260331a0421c87b1b076f26a47457b53b6..3e6dcbabf5a0ce56f9f1ace173fbca9879493241 100755 --- a/bin/run-tests.sh +++ b/bin/run-tests.sh @@ -34,6 +34,12 @@ done # Shift out the options shift $[$OPTIND - 1] +# Create the test directory needed issue.45 test. + +rm -rf test-tmp +mkdir test-tmp +ln -s /bin/ls test-tmp/ls-link + if [ $# -eq 0 ]; then # No args so run all the tests $LISP -noinit -load tests/run-tests.lisp -eval '(cmucl-test-runner:run-all-tests)' diff --git a/src/code/run-program.lisp b/src/code/run-program.lisp index 23abdb349adb29580cb7be5b5721d64985a394e4..9382763720f0dd4efe0bd748435c6699872a4b1f 100644 --- a/src/code/run-program.lisp +++ b/src/code/run-program.lisp @@ -528,10 +528,7 @@ ;; info. Also, establish proc at this level so we can return it. (let (*close-on-error* *close-in-parent* *handlers-installed* proc) (unwind-protect - (let ((pfile (unix-namestring (merge-pathnames program "path:") t t)) - (cookie (list 0))) - (unless pfile - (error (intl:gettext "No such program: ~S") program)) + (let ((cookie (list 0))) (multiple-value-bind (stdin input-stream) (get-descriptor-for input cookie :direction :input @@ -570,7 +567,7 @@ env)) (let ((child-pid (without-gcing - (spawn pfile argv envp pty-name + (spawn program argv envp pty-name stdin stdout stderr)))) (when (< child-pid 0) (error (intl:gettext "Could not fork child process: ~A") diff --git a/src/i18n/locale/cmucl.pot b/src/i18n/locale/cmucl.pot index 36ccbe894d75abde31ddd7895775615b46996e4a..4f128473564ac67eca5037abe06db025fe5ab384 100644 --- a/src/i18n/locale/cmucl.pot +++ b/src/i18n/locale/cmucl.pot @@ -13250,10 +13250,6 @@ msgstr "" msgid "All args to program must be simple strings -- ~S." msgstr "" -#: src/code/run-program.lisp -msgid "No such program: ~S" -msgstr "" - #: src/code/run-program.lisp msgid "Could not fork child process: ~A" msgstr "" diff --git a/src/lisp/runprog.c b/src/lisp/runprog.c index 556c34e0b35fd38a2433eb003cd75296c6c84825..61a9bb8df48a672d6a2d00840f3a14442f37d27e 100644 --- a/src/lisp/runprog.c +++ b/src/lisp/runprog.c @@ -65,10 +65,10 @@ spawn(char *program, char *argv[], char *envp[], char *pty_name, /* Exec the program. */ execve(program, argv, envp); - /* It didn't work, so try /bin/sh. */ + /* It didn't work, so try /usr/bin/env. */ argv[0] = program; - argv[-1] = "sh"; - execve("/bin/sh", argv - 1, envp); + argv[-1] = "/usr/bin/env"; + execve("/usr/bin/env", argv - 1, envp); /* The exec didn't work, flame out. */ exit(1); diff --git a/tests/issues.lisp b/tests/issues.lisp index 1af498f42ec769286ad0186c2867cfdfacb28508..4cb8f20f7c3a8bccca1e97cd610fdf11151de567 100644 --- a/tests/issues.lisp +++ b/tests/issues.lisp @@ -405,3 +405,33 @@ (define-test issue.41.2 (:tag :issues) (issue-41-tester unix:sigtstp)) + +(define-test issue.45 + (:tag :issues) + ;; This depends on run-tests to setup the test directory correctly! + (let* ((test-dir #p"test-tmp/") + (test-dir-name (namestring test-dir))) + (flet ((do-test (program) + (with-output-to-string (s) + (let ((process + (ext:run-program program + (list test-dir-name) + :wait t :output s))) + ;; Verify process exited without error and that we + ;; got the expected output. + (assert-eql 0 + (ext:process-exit-code process)) + (assert-equal "ls-link +" + (get-output-stream-string s)))))) + ;; Test that absolute paths work. + (do-test "/bin/ls") + ;; Test that unspecfied path works. This depends on "ls" being + ;; somewhere in PATH. + (do-test "ls") + ;; Test that relative path to program works. (Issue #45). + (do-test (concatenate 'string + "./" + test-dir-name + "ls-link"))))) +