[pass] Output to less (or another pager)

Kjetil Torgrim Homme kjetil.homme at redpill-linpro.com
Mon Jan 19 16:28:21 CET 2015


On 01/19/2015 02:05 PM, Are wrote:
> In an environment where my terminals may be viewed by others, I would
> prefer to not having my passwords listed in the scrollback buffer. The
> easy solution to this is to pipe the command through a pager like
> 'less'. However, it would be better if this would be automatic and I
> have patched the pass script to make use of the $PAGER variable - if it
> exists and contain something sensible.


        if [[ $clip -eq 0 ]]; then
-           exec $GPG -d "${GPG_OPTS[@]}" "$passfile"
+           if [ -n "${PAGER}" -a $(which ${PAGER}|wc -l) -eq 1 ]; then
+               exec $GPG -d "${GPG_OPTS[@]}" "$passfile" | ${PAGER}
+           else
+               exec $GPG -d "${GPG_OPTS[@]}" "$passfile"
+           fi


which(1) is traditionally a csh script which reads .cshrc(!) to evaluate
the correct $PATH.  needless to say, .cshrc and .bashrc have been known
to diverge.  in modern Linux which(1) has been replaced by a binary, but
still, I think it is better to use the bash builtin if you need to check
this (that is, "type").  in actual fact I think this is superfluous, if
you've set $PAGER you'd better set it to a sensible value.

my preferred way of coding this would be forego the if test and the
duplication of the gpg command line it requires, and instead add a
potential "useless cat" to the command:

-           exec $GPG -d "${GPG_OPTS[@]}" "$passfile"
+           exec $GPG -d "${GPG_OPTS[@]}" "$passfile" | ${PAGER:-cat}

although, since many people probably like the existing behaviour in
pass(1) *and* they have set $PAGER already, I think it is better to make
it opt-in by using a pass(1) specific variable.  my suggested patch is
therefore:

-           exec $GPG -d "${GPG_OPTS[@]}" "$passfile"
+           exec $GPG -d "${GPG_OPTS[@]}" "$passfile" | ${PASS_PAGER:-cat}



-- 
Kjetil T. Homme
Redpill Linpro - Changing the game

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20150119/b04435ef/attachment.asc>


More information about the Password-Store mailing list