[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: System Calls from CLISP



Are you on the clisp mailing list?  I got Bruno Haible's reply to you
directly from them as well as from you.
He really answers everyone fast and is very conscientious!
We should get the new version of Clisp.
Also when I get around to it, I'll have them install the IRIX 2 binaries
on Charlie.



THIS CAME FROM CFGLINUX.LSP:

;; ENGLISH: (edit-file file) edits a file.
;; DEUTSCH: (edit-file file) editiert eine Datei.
;; FRANCAIS: (edit-file file) permet l'‚dition d'un fichier.
(defun edit-file (file)
  (open file :direction :probe :if-does-not-exist :create)
  (shell (format nil "~A ~A" (editor-name) (truename file)))
)

THIS CAME FROM CFGDOS.LSP
Seems to mean that you use shell and a string to run batch file,
execute and a command line for exe files.
There is no definition of shell or execute in the source code I have for
Clisp.

;; ENGLISH: (edit-file file) edits a file.
;; DEUTSCH: (edit-file file) editiert eine Datei.
;; FRANCAIS: (edit-file file) permet l'‚dition d'un fichier.
(defun edit-file (file)
  ; The function EXECUTE apparently crashes on batch files. Work around.
  (let ((editor (editor-name))
        (filename (namestring file t)))
    (if #-OS/2 (string= (pathname-type editor) "BAT")
        #+OS/2 (string-equal (pathname-type editor) "cmd")
      (shell (format nil "~A ~A" editor filename))
      (execute editor filename)
) ) )

FROM USER2.LSP
THERE'S NO DOC, BUT THE CODE SHOULD TELL:

  (defun run-shell-command (command &key (input ':terminal) (output ':terminal)
                                         (if-output-exists ':overwrite)
                                         #+(or UNIX WIN32-UNIX) (may-exec nil))
    (case input
      ((:TERMINAL :STREAM) )
      (t (if (eq input 'NIL)
           (setq input
                 #+(or UNIX WIN32-UNIX) "/dev/null" 
                 #+(or DOS OS/2 WIN32-DOS) "nul")
           (setq input (string input))
         )
         (setq command (string-concat command " < " (shell-quote input)))
    ) )
    (case output
      ((:TERMINAL :STREAM) )
      (t (if (eq output 'NIL)
           (setq output
                 #+(or UNIX WIN32-UNIX) "/dev/null"
                 #+(or DOS OS/2 WIN32-DOS) "nul"
                 if-output-exists ':OVERWRITE
           )
           (progn
             (setq output (string output))
             (when (and (eq if-output-exists ':ERROR) (probe-file output))
               (setq output (pathname output))
               (error-of-type 'file-error
                 :pathname output
                 #L{
                 DEUTSCH "~S: Eine Datei ~S existiert bereits."
                 ENGLISH "~S: File ~S already exists"
                 FRANCAIS "~S : Le fichier ~S existe d‚j…."
                 }
                 'run-shell-command output
         ) ) ) )
         (setq command
               (string-concat command
                 (ecase if-output-exists
                   ((:OVERWRITE :ERROR) " > ")
                   (:APPEND " >> ")
                 )
                 (shell-quote output)
    ) )  )     )
    #+(or UNIX WIN32-UNIX)
    (when may-exec
      ; Wenn die ausfhrende Shell die "/bin/sh" ist und command eine
      ; "simple command" im Sinne von sh(1), k”nnen wir ein wenig optimieren:
      (setq command (string-concat "exec " command))
    )
    (if (eq input ':STREAM)
      (if (eq output ':STREAM)
        (make-pipe-io-stream command)
        (make-pipe-output-stream command)
      )
      (if (eq output ':STREAM)
        (make-pipe-input-stream command)
        (shell command) ; evtl. " &" anfgen, um Hintergrund-Prozeá zu bekommen
    ) )
  )
  (defun run-program (program &key (arguments '())
                                   (input ':terminal) (output ':terminal)
                                   (if-output-exists ':overwrite))
    (run-shell-command
      (apply #'string-concat
             #+(or UNIX WIN32-UNIX) (shell-quote (string program)) 
             #-(or UNIX WIN32-UNIX) (string program)
             (mapcan #'(lambda (argument)
                         (list " " (shell-quote (string argument)))
                       )
                     arguments
      )      )
      #+(or UNIX WIN32-UNIX) :may-exec
      #+(or UNIX WIN32-UNIX) t
      :input input :output output :if-output-exists if-output-exists
  ) )
)

SHELL-QUOTE surrounds a string by single quotes in Unix/Linux, and by
double quotes in DOS and other things.  Comments tell this.  This
too, isn't defined in the lisp source code.

Have you considered the free Allegro linux version?
Might give greater compatibility with the ACL for Windows, which will be
the standard version for my classes.  And the ACL people may continue to be nice
to IIT if everyone is using it.