diff --git a/.local/share/common-lisp/source/ambrevar/shell.lisp b/.local/share/common-lisp/source/ambrevar/shell.lisp index dfece85f..876e845a 100644 --- a/.local/share/common-lisp/source/ambrevar/shell.lisp +++ b/.local/share/common-lisp/source/ambrevar/shell.lisp @@ -3,6 +3,9 @@ (:use #:common-lisp) (:use #:trivia) (:import-from #:fof) + (:import-from #:cmd + #:cmd #:$cmd #:cmd! #:cmd? ;; #:cmd& ; `cmd&' is shadowed below. + #:sh #:$sh #:sh& #:sh! #:sh?) (:import-from #:serapeum #:export-always)) (in-package ambrevar/shell) (eval-when (:compile-toplevel :load-toplevel :execute) @@ -94,35 +97,6 @@ Return the first non-deleted directory." ;; ;; Use -KILL to fix this? ;; (setf *process-list* nil)) -(export-always '*shell*) -(defvar *shell* "sh" - "Default shell to use in `sh' and friends. -Also see `*shell-command-flags*'.") - -(export-always '*shell-command-flag*) -(defvar *shell-command-flag* "-c" - "Flag to pass a command string to the `*shell*'.") - -(defun format-shell-command (shell-command) - (format nil "~a ~a '~a'" - *shell* *shell-command-flag* shell-command)) - -(export-always 'sh) -(defun sh (&rest shell-args) - "Wrapper around `cmd:cmd' to execute SHELL-COMMAND in `*shell*'. -SHELL-ARGS are strings that are concatenated before being sent to the shell." - (cmd:cmd (format-shell-command (str:join "" shell-args)))) - -(export-always 'sh&) -(defun sh& (&rest shell-args) - "Same as `sh' but around `cmd:cmd&'" - (cmd:cmd& (format-shell-command (str:join "" shell-args)))) - -(export-always '$sh) -(defun $sh (&rest shell-args) - "Same as `sh' but around `cmd:$cmd'" - (cmd:$cmd (format-shell-command (str:join "" shell-args)))) - (export-always 'cmd&) (defun cmd& (cmd) ; TODO: Support (cmd &rest args) lambda list. "Like `cmd:cmd&' but run and monitor in a shell. @@ -134,6 +108,7 @@ List of background process is maintained in `*process-list*'." (push handle *process-list*) handle)) +;; See https://github.com/ruricolist/cmd/issues/6 for a discussion. (export-always 'cmd>) (defun cmd> (cmd &rest args) ; TODO: "|" is not convenient in CL, use "/" or "-"? See `cmd<>'. "Like `cmd:cmd&' but return the output as a stream. diff --git a/.local/share/common-lisp/source/ambrevar/syntax.lisp b/.local/share/common-lisp/source/ambrevar/syntax.lisp index c4655740..5eabe410 100644 --- a/.local/share/common-lisp/source/ambrevar/syntax.lisp +++ b/.local/share/common-lisp/source/ambrevar/syntax.lisp @@ -2,7 +2,7 @@ (:documentation "Syntax table.") (:use #:common-lisp) (:use #:trivia) - (:import-from #:ambrevar/shell) + (:import-from #:cmd) (:import-from #:serapeum #:export-always)) (in-package ambrevar/syntax) (eval-when (:compile-toplevel :load-toplevel :execute) @@ -30,14 +30,14 @@ (let ((next-char (read-char stream nil :eof))) (str:string-case (string next-char) ("#" - (ambrevar/shell:sh (read-until stream #\newline))) + (cmd:sh (read-until stream #\newline))) ("!" - (ambrevar/shell:sh (read-until stream #\newline))) + (cmd:sh (read-until stream #\newline))) ("$" - (ambrevar/shell:$sh (read-until stream #\newline))) + (cmd:$sh (read-until stream #\newline))) (otherwise - (ambrevar/shell:sh (str:concat (string next-char) - (read-until stream #\newline))))))) + (cmd:sh (str:concat (string next-char) + (read-until stream #\newline))))))) (export-always 'syntax) (named-readtables:defreadtable ambrevar/syntax::syntax