|
29 | 29 | # <http://www.gnu.org/licenses/gpl.txt>. |
30 | 30 | # |
31 | 31 | # 1}}} |
32 | | -my $VERSION = "2.06"; # odd number == beta; even number == stable |
| 32 | +my $VERSION = "2.07"; # odd number == beta; even number == stable |
33 | 33 | my $URL = "github.com/AlDanial/cloc"; # 'https://' pushes header too wide |
34 | 34 | require 5.10.0; |
35 | 35 | # use modules {{{1 |
@@ -396,7 +396,7 @@ my $getopt_success = GetOptions( # {{{1 |
396 | 396 | "ksep|thousands-delimiter=s" => \$opt_thousands_delimiter , |
397 | 397 | ); |
398 | 398 | $opt_txt = 0; |
399 | | -my $opt_fmt_tempfile = ""; |
| 399 | +my $tmp_file_to_delete = ""; |
400 | 400 | # 1}}} |
401 | 401 | $config_file = $opt_config_file if defined $opt_config_file; |
402 | 402 | load_from_config_file($config_file, # {{{2 |
@@ -6090,6 +6090,12 @@ sub make_file_list { # {{{1 |
6090 | 6090 | push @file_list, "$file_or_dir"; |
6091 | 6091 | } elsif (is_dir($file_or_dir)) { |
6092 | 6092 | push @dir_list, $file_or_dir; |
| 6093 | + } elsif (-p $file_or_dir) { |
| 6094 | + # a pipe via process substitution, eg cloc <(cat cloc) |
| 6095 | + my @lines = <>; |
| 6096 | + $tmp_file_to_delete = "temp_process_substitution_$$"; |
| 6097 | + write_file($tmp_file_to_delete, {}, @lines); |
| 6098 | + push @dir_list, $tmp_file_to_delete; |
6093 | 6099 | } else { |
6094 | 6100 | push @{$raa_errors}, [$rh_Err->{'Neither file nor directory'} , $F]; |
6095 | 6101 | $rh_ignored->{$F} = 'not file, not directory'; |
@@ -7342,7 +7348,7 @@ sub write_file { # {{{1 |
7342 | 7348 | # filename starts with "SCALAR" followed by a memory address in hex. |
7343 | 7349 | # This temporary file will need to be cleaned up before the program ends. |
7344 | 7350 | if ($ON_WINDOWS and (ref($file) eq "SCALAR" or $file =~ /^SCALAR/)) { |
7345 | | - $opt_fmt_tempfile = "$file"; # string version of the file name |
| 7351 | + $tmp_file_to_delete = "$file"; # string version of the file name |
7346 | 7352 | } |
7347 | 7353 | if ($opt_file_encoding) { |
7348 | 7354 | $OUT = open_file(">:encoding($opt_file_encoding)", $file, 0); |
@@ -19182,10 +19188,12 @@ EOAlgDiff |
19182 | 19188 | print "<- Install_Algorithm_Diff\n" if $opt_v > 2; |
19183 | 19189 | } # 1}}} |
19184 | 19190 | END { # {{{1 |
19185 | | - # Remove temp file on Windows if running with --fmt |
19186 | | - if ($ON_WINDOWS and $opt_fmt and $opt_fmt_tempfile) { |
19187 | | - print "-> END unlink $opt_fmt_tempfile\n" if $opt_v > 2; |
19188 | | - unlink($opt_fmt_tempfile) |
| 19191 | + # Temp files might have been created |
| 19192 | + # - on Windows if running with --fmt |
| 19193 | + # - on POSIX if using process substitution, eg, cloc <(cat cloc) |
| 19194 | + if ($tmp_file_to_delete) { |
| 19195 | + print "-> END unlink $tmp_file_to_delete\n" if $opt_v > 2; |
| 19196 | + unlink($tmp_file_to_delete) |
19189 | 19197 | } |
19190 | 19198 | } # 1}}} |
19191 | 19199 | __END__ |
|
0 commit comments