Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,4 @@ parsed at read time and prepared to be executed at runtime.
In the 'bang' forms only simple shell commands can be issued as the
reader does not detect the circumstances when a construct (such as ca
'`case`') occupies more than one line. In the embedded form or with
the script command, any script can be executed.
the script command, any script can be executed.
2 changes: 1 addition & 1 deletion clesh-tests.asd
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
:description ("Unit tests for clesn

To run the tests, load this package and
evaluate (lisp-unit:run-all-tests clesh)"))
evaluate (lisp-unit:run-all-tests clesh-tests)"))
10 changes: 7 additions & 3 deletions clesh-tests.lisp
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
(in-package clesh)
(defpackage #:clesh-tests
(:use #:cl
#:clesh
#:lisp-unit)
(:import-from #:clesh
#:read-interpolated-string))

(eval-when (:compile-toplevel :load-toplevel)
(use-package 'lisp-unit))
(in-package #:clesh-tests)

(define-test read-interpolated-string
(assert-equal
Expand Down
17 changes: 8 additions & 9 deletions clesh.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,11 @@ will be read as (\"asd foo \" (+ 2 2) \" bar \" (+ 3 3))."

(defun simple-shell-escape-reader (stream char)
(declare (ignore char))
(let* ((ll
(apply 'concatenate 'string
(read-interpolated-string stream #\Newline nil t))))
(let* ((ll (apply 'concatenate 'string
(read-interpolated-string stream #\Newline nil t))))
(if (and (> (length ll) 0) (string= (subseq ll 0 1) "!"))
(enter-shell-mode stream)
(princ (script ll))))
(enter-shell-mode stream)
(princ (script ll))))
nil)

(defun embedded-shell-escape-reader (stream char)
Expand All @@ -209,15 +208,15 @@ will be read as (\"asd foo \" (+ 2 2) \" bar \" (+ 3 3))."

(defreadtable clesh:syntax
(:merge :standard)
(:macro-char #\! 'simple-shell-escape-reader nil)
(:macro-char #\[ 'embedded-shell-escape-reader nil)
(:macro-char #\! #'simple-shell-escape-reader nil)
(:macro-char #\[ #'embedded-shell-escape-reader nil)
;; Ignore closing brackets when reading them
(:macro-char #\] #'(lambda (stream char)
(declare (ignore stream char))
(values)))
(:macro-char #\} #'(lambda (stream char)
(declare (ignore stream char))
(values)))
(:dispatch-macro-char #\# #\[ 'template-escape-reader)
(:dispatch-macro-char #\# #\{ 'storable-template-escape-reader))
(:dispatch-macro-char #\# #\[ #'template-escape-reader)
(:dispatch-macro-char #\# #\{ #'storable-template-escape-reader))