Piping stdout to more or less?

Helmut Waitzmann Helmut.Waitzmann@web.de
Mon Aug 27 22:49:02 2001


"Robert A. Knop Jr." <rknop@panisse.lbl.gov> writes:


>When I run either
>
> gpg --decrypt file.gpg | more
>
>or
>
> gpg --output=- file.gpg | more
>
>things don't work as they ought to. I don't see the prompt for the
>password; this is unsurprising, since it's probably lost somewhere in the
>pipe.
No, it's not lost in the pipe. Probably the passphrase prompt goes to stderr (i.e. the terminal) or even to the terminal device (/dev/tty) itself, not to stdout (i.e. the pipe), but unfortunately, because gpg and more are running at the same time, after gpg has written the passphrase prompt, more clears the screen and writes it's prompt, so the passphrase prompt gets overwritten.
>I type my passphrase, and then the cleartext is priunted to the
>screen, along with the More prompt.
Similarly, after gpg has written it's passphrase prompt, it switches the terminal echo off, but more, after it has cleared the screen and written it's prompt, switches the terminal echo on again. So you can see the more prompt and your passphrase as you type it.
>However, none of the more keypresses
>do what I expect; space does not move to the next page, and so
>forth.
[...]
>Instead, all of the keys I press are echoed back to the screen
>after the More prompt at the bottom of the screen.
Then more switches the terminal to noncanonic input mode, i.e. the characters you type are read one at a time, without you having to type a newline character. But then gpg switches the terminal back to canonic input mode, i.e. the characters you type are read line by line with erase-kill-processing enabled.
>Is there a way to get stdout output of gpg piped into a pager, without
>having to first save the cleartext to disk?
So, the cause of your problem is, that gpg and more want to read from the terminal at the same time. To avoid this, you must ensure, that pgp can read the passphrase from your terminal, without beeing disturbed by more, and vice versa. The simplest way to achieve this, is to not start more until gpg has exited. But that implies, as far as I can see, that you cannot use a pipe.