summaryrefslogtreecommitdiff
path: root/scsh-process.scm
diff options
context:
space:
mode:
Diffstat (limited to 'scsh-process.scm')
-rw-r--r--scsh-process.scm21
1 files changed, 9 insertions, 12 deletions
diff --git a/scsh-process.scm b/scsh-process.scm
index 7350edb..bdb40aa 100644
--- a/scsh-process.scm
+++ b/scsh-process.scm
@@ -43,9 +43,7 @@
;; macros
run/collecting run/string run/strings run/port run/file run/sexp run/sexps
- || &&
- (& run-final-thunk maybe-symbol->string)
- (run maybe-symbol->string) (exec-epf maybe-symbol->string))
+ || && (& run-final-thunk maybe->string) (run maybe->string) (exec-epf maybe->string))
(import chicken scheme data-structures)
@@ -55,8 +53,7 @@
;; execve can be used in a sensible way? Scsh has its own PATH, so we could
;; use something similar to that, but it's more work.
(define (exec-path prog . args)
- ;; Args can include numbers and such, too! That's why we're using ->string
- (process-execute (maybe-symbol->string prog) (map ->string args)))
+ (process-execute (maybe->string prog) (map maybe->string args)))
;; TODO: continue-threads argument
(define (fork/pipe #!optional thunk)
@@ -107,9 +104,10 @@
(define %fork/pipe fork/pipe)
(define %fork/pipe+ fork/pipe+)
-(define (maybe-symbol->string s)
- (if (symbol? s) (symbol->string s) s))
-
+(define (maybe->string s)
+ (cond ((string? s) s)
+ ((or (symbol? s) (number? s)) (->string s))
+ (else (error "Expected a string, symbol or number"))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Baroque procedural interface ;;
@@ -220,16 +218,15 @@
((_ (> ?file-name)) (setup-redirection (> 1 ?file-name)))
((_ (>> ?file-name)) (setup-redirection (>> 1 ?file-name)))
((_ (> ?fd ?file-name))
- (duplicate-fileno (file-open (maybe-symbol->string `?file-name)
+ (duplicate-fileno (file-open (maybe->string `?file-name)
(fx+ open/wronly open/creat))
`?fd))
((_ (>> ?fd ?file-name))
- (duplicate-fileno (file-open (maybe-symbol->string `?file-name)
+ (duplicate-fileno (file-open (maybe->string `?file-name)
(fx+ open/wronly (fx+ open/append open/creat)))
`?fd))
((_ (< ?fd ?file-name))
- (duplicate-fileno (file-open (maybe-symbol->string `?file-name)
- open/rdonly)
+ (duplicate-fileno (file-open (maybe->string `?file-name) open/rdonly)
`?fd))
((_ (<< ?fd ?object))
(fork/pipe (lambda () (display ?object))))