Skip to content

Commit

Permalink
removed auto run, now uses explicit command running
Browse files Browse the repository at this point in the history
  • Loading branch information
thintz committed Aug 6, 2012
1 parent 90ce299 commit 591e4e9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
3 changes: 3 additions & 0 deletions macros.scm
@@ -0,0 +1,3 @@
(define-syntax _ (syntax-rules () ((_ . cmd) (run (fold (lambda (e o) (string-append o " " (->string e))) "" 'cmd)))))
(define-syntax _rl (syntax-rules () ((_rl . cmd) (cmd->list (fold (lambda (e o) (string-append o " " (->string e))) "" 'cmd) read-line))))
(define-syntax _rc (syntax-rules () ((_rc f . cmd) (cmd->list (fold (lambda (e o) (string-append o " " (->string e))) "" 'cmd) 'f))))
2 changes: 1 addition & 1 deletion makefile
@@ -1,7 +1,7 @@
# Makefile for Chicken-scheme shell

cscsh: shell.scm
csc shell.scm -o hiss
csc shell.scm -compile-syntax -o hiss

.PHONY: clean
clean:
Expand Down
25 changes: 13 additions & 12 deletions shell.scm
@@ -1,5 +1,6 @@
;;; documentation at http://thintz.com/chicken-scheme-shell
(use readline symbol-utils)
(use readline symbol-utils srfi-1)
(include "macros.scm")

(define (getenv2 e)
;; handles exorcism of getenv from 4.6.4 onwards
Expand All @@ -21,6 +22,8 @@
(define exit? (make-parameter #f))
(define (exit) (exit? #t))

(define (%run-cmd cmd) (with-input-from-pipe cmd read-file))

; now we can can actually use things in a more lispy way
; #;1> (cmd->list "ls" read-line)
; (file1 file2 file3)
Expand All @@ -42,16 +45,14 @@

(define (shell-repl)
(if (exit?)
#t
(let ((x (read)))
(handle-exceptions
exn
(begin (print-error-message exn)
(display (with-output-to-string (lambda () (print-call-chain)))))
(if (unbound? x)
(run (symbol->string x))
(display (eval x)))
(newline))
(shell-repl))))
#t
(begin (handle-exceptions
exn
(begin (print-error-message exn)
(display (with-output-to-string (lambda () (print-call-chain)))))
(let ((x (read)))
(write (eval x))))
(newline)
(shell-repl))))

(shell-repl)

0 comments on commit 591e4e9

Please sign in to comment.