ext:system — Invoke a command using the shell.


(ext:system command)


A string


An integer (0-255) with the exit code of the program


This function executes a command in the shell. In Unix systems, typically the environment variable SHELL determines which program will be invoked, while in Windows CMD.EXE is used. The string may thus be any valid command that the shell accepts and in can contain higher level elements such as input/output redirection. Output isn't printed.

As an example, the following function uses an external editor to modify a lisp file and, if successful, loads the changed sources:

(defun edit (filename)
  (let* ((editor #+windows "notepad.exe"
                 #-windows "/usr/bin/emacs")
    (command (concatenate 'string editor " " filename)))
    (when (zerop (ext:system command))
    (load filename))))