A Lisp implemented in AWK
;; SPDX-License-Identifier: BSD-2-Clause

(macro set-x (lambda (args)
               `(if (memq :set-x *log-tags*)
                    (let ((ossc *show-system-command*))
                      (setq *show-system-command* log-command)
                      (prog1
                          (progn ,@args)
                        (setq *show-system-command* ossc)))
                  (progn ,@args))))

;;
;; This is something like a distant child of an Either monad and the
;; "set -e" mechanism whereby shells quit when errors happen.
;;

(defun system-or-error args
  (let ((rv (apply system args)))
    (when (not (eq rv 0))
      (error "system with arguments %s returned exitcode %d" (repr args) rv))
    rv))

(defun some-output-or-error args
  (let ((output (apply output-of args)))
    (if (equal "" output)
        (error "command %s returned no output" (repr args))
      output)))