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. In the examples below, he program is called from the command line (bash).
First try:
#!/usr/bin/emacs --script
(setq passwd-file "~/password.gpg")
(save-excursion
(let ((passwd-buffer (find-file passwd-file)))
(switch-to-buffer passwd-buffer)
(princ (buffer-substring 1 30))))
This lets me enter the password in the terminal, but the password is shown in plaintext.
Second try
#!/usr/bin/emacs --script
(setq passwd-file "~/password.gpg")
(setq pstring (shell-command-to-string (concat "gpg -d " passwd-file)))
(princ pstring)
This gives the error gpg: cannot open tty /dev/tty: No such device or address