Re: [PATCHv4] Add contrib/credentials/netrc with GPG support
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Feb 5, 2013, 22:09 UTC
- Message-ID
- <7vpq0equo9.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <877gmmqyho.fsf@lifelogs.com>
Ted Zlatanov <tzz@lifelogs.com> writes:
Show 24 quoted lines
> On Tue, 05 Feb 2013 11:53:20 -0800 Junio C Hamano <gitster@pobox.com> wrote:
>
> I think it's more readable with large loops, and it actually makes sense
> when you read the code. Not a big deal to me either, I just felt for
> this particular script it was OK.
>
>>> + if ($file =~ m/\.gpg$/) {
>>> + log_verbose("Using GPG to open $file");
>>> + # GPG doesn't work well with 2- or 3-argument open
>
> JCH> If that is the case, please quote $file properly against shell
> JCH> munging it.
>
> Ahhh that gets ugly. OK, quoted.
>
> JCH> The only thing you do on $io is to read from it via "while (<$io>)",
> JCH> so I would personally have written this part like this without
> JCH> having to use IO::File(), though:
>
> JCH> $io = open("-|", qw(gpg --decrypt), $file);
>
> That doesn't work for me, unfortunately. I'm trying to avoid the IPC::*
> modules and such. Please test it yourself with GPG. I'm on Perl
> 5.14.2.This works for me as expected (sorry for that open $io syntax gotcha).
-- cut here -- >8 -- cut here --
#!/usr/bin/perl
my $io;
open $io, "-|", qw(gpg --decrypt), $ARGV[0]
or die "$!: gpg open";
while (<$io>) {
print;
}
close $io
or die "$!: gpg close";-- cut here -- 8< -- cut here --
$ perl --version This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi