anchor.diff:      ; TODO really needs to be from a config.lisp
       ; a low timeout isn't too terrible unless the REPL is picky about
       ; timing or the user dislikes the REPL replay looking like trash
  -    (strcase command
  -             ("ecl" (psetf expect "> " lisp t))
  -             ("lol" (psetf expect "SBCL> " lisp t))
  -             ("sbcl" (psetf expect "* " lisp t))
  -             ("expect" (psetf readfn #'redo-readline expect "expect"))
  -             ("gdb" (psetf expect "gdb"))
  -             ("egdb" (psetf expect "gdb"))
  -             ("gforth" (psetf expect #.(format nil "ok~c" #\newline)
  -                              seconds 0.01 nixline "^\\s*\\\\\\s+"))
  -             ; ... but would need regex to match the whole Stack<...
  -             ; line so meanwhile probably use this with -q
  -             ("pforth" (psetf expect #.(format nil "ok~c" #\newline)
  -                              seconds 0.01 nixline "^\\s*\\\\\\s+"))
  -             ("sh" (psetf readfn #'redo-readline))
  -             ("jsh" (psetf readfn #'redo-readline)) ; Heirloom Bourne Shell
  -             ("ksh" (psetf readfn #'redo-readline))
  -             ("mksh" (psetf readfn #'redo-readline))
  -             ("zsh" (psetf readfn #'redo-readline))
  -             ("sqlite" (psetf readfn #'redo-readline expect "sqlite>"))
  -             ("tclsh" (psetf readfn #'redo-readline expect "tclsh>"))
  -             )
  +    (recase command
  +            ("^ecl" (psetf expect "> " lisp t))
  +            ("^lol" (psetf expect "SBCL> " lisp t))
  +            ("^sbcl" (psetf expect "* " lisp t))
  +            ("^expect" (psetf readfn #'redo-readline expect "expect"))
  +            ("^e?gdb" (psetf expect "gdb"))
  +            ; ... but would need regex to match the whole Stack<...
  +            ; line so meanwhile probably use pforth -q
  +            ("^[gp]forth" (psetf expect #.(format nil "ok~c" #\newline)
  +                                 seconds 0.01 nixline "^\\s*\\\\\\s+"))
  +            ("^(?:mk|[jk])?sh" (psetf readfn #'redo-readline))
  +            ("^sqlite" (psetf readfn #'redo-readline expect "sqlite>"))
  +            ("^tclsh" (psetf readfn #'redo-readline expect "tclsh>"))
  +            ("^zsh" (psetf readfn #'redo-readline expect "% "))
  +            )
       (if lisp
         (external-interact-lisp command pty stream expect seconds)
         (external-interact command pty stream readfn expect nixline seconds))))
  
positive.code: ;
  ; EXTERNAL COMMAND
  
  (defparameter *buf*
    (make-array 4096 :adjustable t :element-type 'extended-char
                :fill-pointer 0)
  
negative.code:           (when (funcall match ch) (return))))
      (sb-sys:deadline-timeout ())))
  
  (defun maybe-readline (stream regex)
    "Read lines but maybe skipping some of them."
    (block nil
      (tagbody getaline
        (multiple-value-bind (line miss-nl) (read-line stream t)
          (unless (match line regex)
            (return (values line miss-nl))))
        (go getaline))))
  
  