Permalink
Browse files

Moved the utility functions to a new file and out of the API definition.

  • Loading branch information...
1 parent 48ff334 commit 8e4dab79c5f2e0ce52c76d763b7c85a7d0202d0b @sellout committed Jan 16, 2011
Showing with 31 additions and 29 deletions.
  1. +2 −1 external-program.asd
  2. +0 −28 src/external-program.lisp
  3. +29 −0 src/utilities.lisp
View
3 external-program.asd
@@ -12,6 +12,7 @@
:version "0.0.6"
:pathname "src/"
:components ((:file "external-program")
+ (:file "utilities" :depends-on ("external-program"))
(:file #+allegro "allegro"
#+armedbear "armedbear"
#+clisp "clisp"
@@ -27,7 +28,7 @@
#-(or allegro armedbear clisp cmu ecl lispworks openmcl
sbcl)
"unsupported"
- :depends-on ("external-program")))
+ :depends-on ("utilities")))
:in-order-to ((test-op (load-op external-program-test)))
:perform (test-op :after (op c)
(funcall (intern "RUN!" :external-program-tests)
View
28 src/external-program.lisp
@@ -162,31 +162,3 @@ the process changes. The function takes the process as an argument.")
(:bad-system-call . 12)
(:broken-pipe . 13)
(:alarm-clock . 14)))
-
-(defun rename-parameter (from-name to-name rest)
- (setf (getf rest to-name) (getf rest from-name))
- (remf rest from-name)
- rest)
-
-(defun stringify-args (args)
- (mapcar (lambda (arg)
- (typecase arg
- (sequence (coerce arg 'string))
- ((or symbol character) (string arg))
- (number (format nil "~a" arg))
- (pathname (namestring arg))))
- args))
-
-(defun reformat-environment (environment)
- "SBCL accepts vars as either (\"FOO=meh\" ...) or ((:foo . \"meh\")
- ...), but not ((\"FOO\" . \"meh\") ...), so we build up the first
- kind (since the second kind is potentially lossy)."
- ;; FIXME: probably need to escape single-quotes and backslashes
- (mapcar (lambda (var) (format nil "~a=~s" (car var) (cdr var))) environment))
-
-(defun make-shell-string (program args environment replace-environment-p)
- (format nil "~:[~;env -i PATH=''~] ~:{~a=~s ~}~a~{ ~s~}"
- replace-environment-p
- (reformat-environment environment)
- program
- (stringify-args args)))
View
29 src/utilities.lisp
@@ -0,0 +1,29 @@
+(in-package #:external-program)
+
+(defun rename-parameter (from-name to-name rest)
+ (setf (getf rest to-name) (getf rest from-name))
+ (remf rest from-name)
+ rest)
+
+(defun stringify-args (args)
+ (mapcar (lambda (arg)
+ (typecase arg
+ (sequence (coerce arg 'string))
+ ((or symbol character) (string arg))
+ (number (format nil "~a" arg))
+ (pathname (namestring arg))))
+ args))
+
+(defun reformat-environment (environment)
+ "SBCL accepts vars as either (\"FOO=meh\" ...) or ((:foo . \"meh\")
+ ...), but not ((\"FOO\" . \"meh\") ...), so we build up the first
+ kind (since the second kind is potentially lossy)."
+ ;; FIXME: probably need to escape single-quotes and backslashes
+ (mapcar (lambda (var) (format nil "~a=~s" (car var) (cdr var))) environment))
+
+(defun make-shell-string (program args environment replace-environment-p)
+ (format nil "~:[~;env -i PATH=''~] ~:{~a=~s ~}~a~{ ~s~}"
+ replace-environment-p
+ (reformat-environment environment)
+ program
+ (stringify-args args)))

0 comments on commit 8e4dab7

Please sign in to comment.