Re: How to run from command line?
Pascal Bourguignon <[email protected]>
| Newsgroups | gmane.lisp.clisp.general |
|---|---|
| Message-ID | <[email protected]> |
> On 30 Dec 2016, at 12:21, Jean Louis <[email protected]> wrote: > > On Sat, Dec 24, 2016 at 01:36:20PM +0100, Pascal Bourguignon wrote: >>> How would I create executable image? How do you do it? >> >> http://www.clisp.org/impnotes/image.html <http://www.clisp.org/impnotes/image.html> >> >> (load “your-program.lisp”) >> (ext:saveinitmem “your-program” :executable t :norc t :init-function ‘cl-user::main) > > While this is working well, when I use (error function below and > *args* is missing, and if I run it as executable image created as by > the upper line, I get into the REPL. This is good sometimes, for > program execution. > > I was expecting though not to get into the REPL after (error -- but > that error is shown and that I exit. I see from HyperSpec it is > invoking a debugger. I did not find if it is possible to not invoke > the debugger, as it is not invoking debugger when run as: clisp program.cl > > Jean Louis > > (defun main nil > (unless (car *args*) > (error "No valid file specified") > (exit 1)) > (setf json-file (truename (car ext:*args*))) > (unless (probe-file json-file) > (error (format nil "File not readable: ~a") json-file)) > (setf sms-json (cl-json:decode-json-from-source json-file)) > (let ((message (ask-for-message))) > (loop for i in sms-json > do (let ((number (normalize-number (cdr (assoc :number i)))) > (name (first-name (cdr (assoc :name i))))) > (when (tanzanian? number) > ;; (if (regexp:match "^0" number) (progn (push > ;; (first-four number) fournr) > > ;; (format t "~a~%" (first-four > ;; number))))))))) just to add (anssh to run the > ;; commands... > (format t "~a~%" (termux-sms-send > number (replace-string "NAME" name message) name)))))) > (exit)) > If you want to handle the errors, then handle them yourself: (ext::saveinitmem program-name :executable t :norc t :quiet t :verbose t :script t :documentation program-documentation-string :start-package (find-package "COMMON-LISP-USER") ;; :locked-packages ;; :keep-global-handlers :init-function (lambda () (handler-case (progn (load program-init-file :if-does-not-exist nil) (funcall program-main-function ext:*args*)) (error (err) (finish-output *standard-output*) (finish-output *trace-output*) (format *error-output* "~%~A~%" err) (finish-output *error-output*) (ext:exit 1))) (finish-output *standard-output*) (finish-output *trace-output*) (ext:exit 0))) -- __Pascal J. Bourguignon__ ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ clisp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/clisp-list