App-Greple
view release on metacpan or search on metacpan
If the command doesn't accept standard input as processing data, you
may be able to use special device:
greple --if='nm /dev/stdin' crypt /usr/lib/lib*
Filters for compressed and gzipped file is set by default unless
`--noif` option is given. Default action is like this:
greple --if='s/\.Z$//:zcat' --if='s/\.g?z$//:gunzip -c'
File with `.gpg` suffix is filtered by **gpg** command. In that case,
pass-phrase is asked for each file. If you want to input pass-phrase
only once to find from multiple files, use `-Mpgp` module.
If the filter starts with `&`, perl subroutine is called instead of
external command. You can define the subroutine in `.greplerc` or
modules. **Greple** simply call the subroutine, so it should be
responsible for process control. It may have to use `POSIX::_exit()`
to avoid executing an `END` block on exit or calling destructor on
the object.
lib/App/Greple/PgpDecryptor.pm view on Meta::CPAN
: $obj->{FH};
}
sub pgppassfd {
my $obj = shift;
$obj->fh->fileno;
}
sub decrypt_command {
my $obj = shift;
my $command = "gpg";
my @option = ( qw(--quiet --batch --decrypt) ,
qw(--no-tty --no-mdc-warning) );
sprintf "$command @option --passphrase-fd %d", $obj->pgppassfd;
}
sub reset {
my $obj = shift;
defined $obj->fh or return;
$obj->fh->sysseek(0, 0) or die $!;
}
lib/App/Greple/pgp.pm view on Meta::CPAN
=head1 NAME
pgp - Greple module to handle PGP encrypted files
=head1 SYNOPSIS
greple -Mpgp pattern *.gpg
greple -Mpgp --pgppass 'passphrase' pattern file.gpg
=head1 DESCRIPTION
Enables searching within PGP/GPG encrypted files. Files with
I<.pgp>, I<.gpg>, or I<.asc> extensions are automatically decrypted.
Passphrase is requested interactively once and cached for subsequent
files.
=head1 REQUIREMENTS
This module requires the B<gpg> (GnuPG) command to be installed and
available in PATH.
=head1 OPTIONS
=over 7
=item B<--pgppass> I<passphrase>
Specify the PGP passphrase directly. B<Not recommended> for security
reasons as the passphrase may be visible in process listings or shell
lib/App/Greple/pgp.pm view on Meta::CPAN
Decrypted content is processed through pipes and not written to disk.
=item *
Avoid using B<--pgppass> option in scripts or command history.
=back
=head1 SEE ALSO
L<App::Greple>, L<gpg(1)>
=cut
package App::Greple::pgp;
use v5.24;
use warnings;
use Carp;
use App::Greple::PgpDecryptor;
lib/App/Greple/pgp.pm view on Meta::CPAN
if ($pid == 0) {
exec $pgp->decrypt_command or die $!;
}
$pid;
}
1;
__DATA__
option default --if s/\\.(pgp|gpg|asc)$//:&__PACKAGE__::filter
builtin pgppass=s $opt_pgppass // pgp passphrase
script/greple view on Meta::CPAN
##
## setup input/output filter
##
my $filter_d = App::Greple::Filter->new->parse(@opt_if);
unless ($opt_noif) {
$filter_d->append(
[ sub { s/\.Z$// }, 'zcat' ],
[ sub { s/\.g?z$// }, 'gunzip -c' ],
[ sub { m/\.pdf$/i }, 'pdftotext -nopgbrk - -' ],
[ sub { s/\.gpg$// }, 'gpg --quiet --no-mdc-warning --decrypt' ],
);
}
##------------------------------------------------------------
## miscellaneous setups
##
my @argv_files;
my $start_directory;
my $need_filename = ($opt_H or $opt_l);
script/greple view on Meta::CPAN
If the command doesn't accept standard input as processing data, you
may be able to use special device:
greple --if='nm /dev/stdin' crypt /usr/lib/lib*
Filters for compressed and gzipped file is set by default unless
C<--noif> option is given. Default action is like this:
greple --if='s/\.Z$//:zcat' --if='s/\.g?z$//:gunzip -c'
File with C<.gpg> suffix is filtered by B<gpg> command. In that case,
pass-phrase is asked for each file. If you want to input pass-phrase
only once to find from multiple files, use C<-Mpgp> module.
If the filter starts with C<&>, perl subroutine is called instead of
external command. You can define the subroutine in F<.greplerc> or
modules. B<Greple> simply call the subroutine, so it should be
responsible for process control. It may have to use C<POSIX::_exit()>
to avoid executing an C<END> block on exit or calling destructor on
the object.
script/greple view on Meta::CPAN
=cut
# LocalWords: greple egrep foo baz yabba dabba doo ascii greplerc
# LocalWords: regex readlist iname jpg jpeg gif png tbz tgz pdf RGB
# LocalWords: perlre fgrep grep perl joinby KATAKANA InKatakana utf
# LocalWords: nonewline filestyle linestyle chdir mtime nocolor jis
# LocalWords: STDOUT colormap Cyan BLOCKEND LESSANSIENDCHARS setuid
# LocalWords: sprintf regioncolor uniqcolor ansicolor nocolorful jp
# LocalWords: struct sockaddr blockend icode euc shiftjis sjis zcat
# LocalWords: ocode gunzip gpg FILELABEL substr eval misc unicode
# LocalWords: GREPLEOPTS shellwords Katakana builtin pgp autoload
# LocalWords: ENV App ARGV mg Kazumasa Utashiro github colorindex
# LocalWords: matchcount gzipped stdin func CPANMINUS cpanm kana
( run in 0.901 second using v1.01-cache-2.11-cpan-df04353d9ac )