Skip to content

modify run-program and added ccl #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 38 additions & 14 deletions repo.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,45 @@
(format t "~&$ ~A~{ ~A~}~%" cmd args)
(let ((out (make-string-output-stream))
(err (make-string-output-stream)))
(let* ((process (sb-ext:run-program cmd args
:output out
:error err
:external-format :utf-8))
(exit-code (sb-ext:process-exit-code process)))
(unwind-protect
(let* ((process (sb-ext:run-program cmd args
:output out
:error err
:external-format :utf-8))
(exit-code (sb-ext:process-exit-code process))
(out-str (get-output-stream-string out))
(err-str (get-output-stream-string err)))
(format t "~&~A~&" out-str)
(format t "~&~A~&" err-str)
(unless (= 0 exit-code)
(with-simple-restart (continue "Ignore command error")
(error "~&$ ~A~{ ~A~}~%~A" cmd args err-str)))
(values out-str err-str exit-code))
(close out)
(close err)
(let ((out (get-output-stream-string out))
(err (get-output-stream-string err)))
(format t "~&~A~&" out)
(format t "~&~A~&" err)
(unless (= 0 exit-code)
(with-simple-restart (continue "Ignore command error")
(error "~&$ ~A~{ ~A~}~%~A" cmd args err)))
(values out err exit-code)))))
(close err))))

#+ccl
(defun run-program (cmd &rest args)
(format t "~&$ ~A~{ ~A~}~%" cmd args)
(let ((out (make-string-output-stream))
(err (make-string-output-stream)))
(unwind-protect
(let* ((process (ccl:run-program cmd args
:wait nil
:output out
:error err
:external-format :utf-8))
(exit-code (ccl:external-process-status process))
(out-str (get-output-stream-string out))
(err-str (get-output-stream-string err)))
(format t "~&~A~&" out-str)
(format t "~&~A~&" err-str)
(unless (eql :running exit-code)
(with-simple-restart (continue "Ignore command error")
(error "~&$ ~A~{ ~A~}~%~A" cmd args err-str)))
(values out-str err-str exit-code))
(close out)
(close err))))

#-windows
(defun sh (&rest parts)
Expand Down