0

This works:

(make-process :name "test"
      :command (list "bash" "-c"
     (concat "echo hello stdout!; "
     "echo hello stderr! >&2; "
     "exit 20"))
      :buffer (generate-new-buffer "*stdout*")
      ;;:stderr (generate-new-buffer "*stderr*")
              ;;:noquery nil
              )

but, I want this code to work:

(make-process :name "test"
          :command (list "bash" "-c"
                 (concat "echo hello stdout!; "
                     "echo hello stderr! >&2; "
                                     "echo enter your name; "
                                     "read name; "
                                     "echo enterted name was $name; "
                     "exit 0"))
          :buffer (generate-new-buffer "*stdout*")
          ;;:stderr (generate-new-buffer "*stderr*")
              ;;:noquery nil
              )

In other words, when the process sits and waits for user input, the end user should be prompted in the emacs echo area. (I think tramp does something like this when it encounters a password prompt)

not part of this SO question, but eventually I would like to integrated the solution in to (defun org-babel-sh-evaluate (session body &optional params stdin cmdline) of https://code.orgmode.org/bzg/org-mode/src/master/lisp/ob-shell.el

american-ninja-warrior
  • 3,773
  • 2
  • 21
  • 40

1 Answers1

1

TRAMP does a pretty ugly hack to detect a network process prompting for input, it uses regex matching to detect a printed prompt, then asks for user input using tramp-read-passwd. This will obviously not work with your example as there's no matchable prompt to look for.

I doubt there's a generic solution to this considering how reading user input works in a terminal application. User input is read in whenever requested from standard input, with your keyboard (or any input redirection) hooked up to it. Prompts are printed to signal the user they're expected to type in something. If you run a subprocess from Emacs there is no way to tell when user input is read in from the application, other than by trying to look for hints intended for humans (such as the printed prompt).

wasamasa
  • 21,803
  • 1
  • 65
  • 97