Skip to content

Commit

Permalink
Quit immediately when SIGINT is received.
Browse files Browse the repository at this point in the history
  • Loading branch information
fukamachi committed Mar 22, 2017
1 parent 44eeeff commit e6e1054
Showing 1 changed file with 52 additions and 50 deletions.
102 changes: 52 additions & 50 deletions roswell/qlot.ros
Original file line number Diff line number Diff line change
Expand Up @@ -26,56 +26,58 @@ exec ros +Q -- $0 "$@"

(defun main (&optional $1 &rest argv)
(declare (ignorable argv))
(cond ((equal "install" $1)
(when (and (first argv)
(not (probe-file (first argv))))
(print-error "'~A' does not found." (first argv)))
(ros:quicklisp)
(uiop:symbol-call :ql :quickload :qlot :silent t)
(if argv
(uiop:symbol-call :qlot :install (probe-file (first argv)))
(uiop:symbol-call :qlot :install)))
((equal "update" $1)
(when (and (first argv)
(not (probe-file (first argv))))
(print-error "'~A' does not found." (first argv)))
(ros:quicklisp)
(uiop:symbol-call :ql :quickload :qlot :silent t)
(if argv
(uiop:symbol-call :qlot :update (probe-file (first argv)))
(uiop:symbol-call :qlot :update)))
((equal "bundle" $1)
(ros:quicklisp)
(uiop:symbol-call :ql :quickload :qlot :silent t)
(uiop:symbol-call :qlot :bundle))
((equal "exec" $1)
;; Set QUICKLISP_HOME ./quicklisp/
(unless (ros:getenv "QUICKLISP_HOME")
(setenv "QUICKLISP_HOME" "quicklisp/"))
(let ((path (or (probe-file (ros:getenv "QUICKLISP_HOME"))
(merge-pathnames (ros:getenv "QUICKLISP_HOME")
(make-pathname :defaults *load-pathname* :name nil :type nil)))))
(unless (probe-file path)
(print-error "'~A' does not exist."
(ros:getenv "QUICKLISP_HOME")))
(unless (probe-file (merge-pathnames "setup.lisp" path))
(print-error "Invalid Quicklisp directory: '~A'"
(ros:getenv "QUICKLISP_HOME"))))
(handler-case
(cond ((equal "install" $1)
(when (and (first argv)
(not (probe-file (first argv))))
(print-error "'~A' does not found." (first argv)))
(ros:quicklisp)
(uiop:symbol-call :ql :quickload :qlot :silent t)
(if argv
(uiop:symbol-call :qlot :install (probe-file (first argv)))
(uiop:symbol-call :qlot :install)))
((equal "update" $1)
(when (and (first argv)
(not (probe-file (first argv))))
(print-error "'~A' does not found." (first argv)))
(ros:quicklisp)
(uiop:symbol-call :ql :quickload :qlot :silent t)
(if argv
(uiop:symbol-call :qlot :update (probe-file (first argv)))
(uiop:symbol-call :qlot :update)))
((equal "bundle" $1)
(ros:quicklisp)
(uiop:symbol-call :ql :quickload :qlot :silent t)
(uiop:symbol-call :qlot :bundle))
((equal "exec" $1)
;; Set QUICKLISP_HOME ./quicklisp/
(unless (ros:getenv "QUICKLISP_HOME")
(setenv "QUICKLISP_HOME" "quicklisp/"))
(let ((path (or (probe-file (ros:getenv "QUICKLISP_HOME"))
(merge-pathnames (ros:getenv "QUICKLISP_HOME")
(make-pathname :defaults *load-pathname* :name nil :type nil)))))
(unless (probe-file path)
(print-error "'~A' does not exist."
(ros:getenv "QUICKLISP_HOME")))
(unless (probe-file (merge-pathnames "setup.lisp" path))
(print-error "Invalid Quicklisp directory: '~A'"
(ros:getenv "QUICKLISP_HOME"))))

;; Overwrite CL_SOURCE_REGISTRY to the current directory
(setenv "CL_SOURCE_REGISTRY" (namestring *default-pathname-defaults*))
;; Overwrite CL_SOURCE_REGISTRY to the current directory
(setenv "CL_SOURCE_REGISTRY" (namestring *default-pathname-defaults*))

;; Add ~/.roswell/bin to $PATH
(setenv "PATH"
(format nil "~A:~A"
(merge-pathnames "bin/" (roswell.util:homedir))
(ros:getenv "PATH")))
;; Add ~/.roswell/bin to $PATH
(setenv "PATH"
(format nil "~A:~A"
(merge-pathnames "bin/" (roswell.util:homedir))
(ros:getenv "PATH")))

(let ((command (which (first argv))))
(unless command
(print-error "Command not found: ~A" (first argv)))
(ros:exec (cons command (rest argv)))))
(t (format *error-output*
"~&Usage: ~A [install | update | bundle | exec shell-args..]~%"
(file-namestring *load-pathname*))
(ros:quit 1))))
(let ((command (which (first argv))))
(unless command
(print-error "Command not found: ~A" (first argv)))
(ros:exec (cons command (rest argv)))))
(t (format *error-output*
"~&Usage: ~A [install | update | bundle | exec shell-args..]~%"
(file-namestring *load-pathname*))
(ros:quit 1)))
#+sbcl (sb-sys:interactive-interrupt () (uiop:quit -1 nil))))

0 comments on commit e6e1054

Please sign in to comment.