Re: [PATCHv4] Add contrib/credentials/netrc with GPG support
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:56:04
Ted Zlatanov [off-list ref] writes:
On Tue, 05 Feb 2013 11:53:20 -0800 Junio C Hamano [off-list ref] 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.quoted
quoted
+ if ($file =~ m/\.gpg$/) { + log_verbose("Using GPG to open $file"); + # GPG doesn't work well with 2- or 3-argument openJCH> 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