How do I handle password prompts when calling elisp from the terminal

前端 未结 1 1631
闹比i
闹比i 2021-01-16 01:17

I\'m trying to use elisp as a shell script language. I\'m writing a script where I need access to a file encrypted with gpg. I\'m not sure how to handle the password prompt.

相关标签:
1条回答
  • 2021-01-16 02:07

    You are likely out of luck. You first example suggests that even read-passwd does not hide the password input in a non-interactive session, as insert-file calls out to EPA for encrypted files, which in turn uses read-passwd for GPG password input.

    Try to report this to the Emacs maintainers with M-x report-emacs-bug, asking them to suppress input echo in read-passwd in non-interactive sessions. That'd be the behaviour I'd expect.

    For now, you cannot work around this limitation, because Emacs does not expose the underlying TTY to Emacs Lisp code, so you have no chance to manually disable input echo on the underlying TTY device.

    From my experience in writing and contributing quite some non-interactive Emacs Lisp programs, I'd personally advise against using Emacs for non-interactive scripts. It's a poor platform for such programs. The API is limited, and there is a lot of implicit behaviour standing in the way of non-interactive programs, which you can't get rid of.

    For instance, you cannot safely pass command line arguments to Emacs, since Emacs will automatically visit any existing file in its command line arguments, triggering all sorts of side effects such as prompts for unsafe local variables, etc.

    0 讨论(0)
提交回复
热议问题