]> git.pld-linux.org Git - packages/prename.git/blob - prename-1.9-namechange.patch
- from fc
[packages/prename.git] / prename-1.9-namechange.patch
1 diff -up rename-1.9/bin/prename.PL.namechange rename-1.9/bin/prename.PL
2 --- rename-1.9/bin/prename.PL.namechange        2016-10-17 17:31:39.880383236 +0200
3 +++ rename-1.9/bin/prename.PL   2016-10-17 17:34:18.273317178 +0200
4 @@ -0,0 +1,466 @@
5 +use Config;
6 +use File::Basename qw(basename dirname);
7 +
8 +($VERSION)=' $Id: prename.PL,v 1.9 Exp $ '=~/v\s*(\d+(?:\.\d+)+)/;
9 +
10 +chdir(dirname($0));
11 +($file = basename($0)) =~ s/\.PL$//;
12 +$file =~ s/\.pl$//
13 +        if ($Config{'osname'} eq 'VMS' or
14 +            $Config{'osname'} eq 'OS2');  # "case-forgiving"
15 +open OUT,">$file" or die "Can't create $file: $!";
16 +chmod(0755, $file);
17 +print "Extracting $file\n";
18 +
19 +print OUT <<"!DO!SUBST!";
20 +$Config{'startperl'}
21 +
22 +#line 18
23 +
24 +use strict;
25 +
26 +use Getopt::Long;
27 +use Text::Abbrev;
28 +use File::Basename;
29 +use File::Glob ':bsd_glob';
30 +
31 +my \$VERSION = '$VERSION';
32 +
33 +!DO!SUBST!
34 +
35 +print OUT<<'!NO!SUBST!';
36 +Getopt::Long::config(qw(bundling));
37 +$Getopt::Long::prefix = '--';
38 +
39 +my $ME = $0;
40 +($ME = $0) =~ s!.*/!!;
41 +$| = 1;
42 +
43 +my $opt_dryrun          = 0;
44 +my $opt_backup          = 0;
45 +my $opt_force           = 0;
46 +my $opt_interactive     = 0;
47 +my $opt_verbose         = 0;
48 +my $opt_help            = 0;
49 +my $opt_stdin           = 1;
50 +my $opt_version         = 0;
51 +my $opt_linkonly        = 0;
52 +my $opt_prefix          = '';
53 +my $opt_suffix          = '';
54 +my $opt_basename_prefix = '';
55 +my $opt_vcm             = $ENV{RENAME_VERSION_CONTROL}
56 +                        || $ENV{VERSION_CONTROL}
57 +                        || 'existing';
58 +
59 +sub VCM_SIMPLE   { 0 }
60 +sub VCM_TEST     { 1 }
61 +sub VCM_NUMBERED { 2 }
62 +
63 +my $vcm;
64 +
65 +sub error {
66 +    my($ERROR) = @_;
67 +    print "$ME: $ERROR\n";
68 +    print "Try `$ME --help' for more information.\n";
69 +    exit 1;
70 +}
71 +
72 +{
73 +    local $SIG{__WARN__} = sub {
74 +       if ($_[0] =~ /^Unknown option: (\S+)/) {
75 +           error("unrecognized option `--$1'");
76 +       }
77 +        else {
78 +           print @_;
79 +       }
80 +    };
81 +    GetOptions(
82 +              'b|backup'             => \$opt_backup,
83 +               'B|prefix=s'           => \$opt_prefix,
84 +              'f|force'              => \$opt_force,
85 +              'h|help'               => \$opt_help,
86 +              'i|interactive'        => \$opt_interactive,
87 +               'l|link-only'          => \$opt_linkonly,
88 +              'n|just-print|dry-run' => \$opt_dryrun,
89 +               's|stdin!'             => \$opt_stdin,
90 +              'version'              => \$opt_version,
91 +              'v|verbose'            => \$opt_verbose,
92 +              'V|version-control=s'  => \$opt_vcm,
93 +               'Y|basename-prefix=s'  => \$opt_basename_prefix,
94 +              'z|S|suffix=s'         => \$opt_suffix,
95 +             );
96 +}
97 +
98 +if ($opt_version) {
99 +    print "$ME $VERSION\n";
100 +    exit 0;
101 +}
102 +
103 +if ($opt_help) {
104 +    print<<HELP;
105 +Usage: $ME [OPTION]... PERLEXPR FILE...
106 +Rename FILE(s) using PERLEXPR on each filename.
107 +
108 +  -b, --backup                  make backup before removal
109 +  -B, --prefix=SUFFIX           set backup filename prefix
110 +  -f, --force                   remove existing destinations, never prompt
111 +  -i, --interactive             prompt before overwrite
112 +  -l, --link-only               link file instead of reame
113 +  -n, --just-print, --dry-run   don't rename, implies --verbose
114 +  -v, --verbose                 explain what is being done
115 +  -V, --version-control=METHOD  override the usual version control
116 +  -Y, --basename-prefix=PREFIX  set backup filename basename prefix
117 +  -z, -S, --suffix=SUFFIX       set backup filename suffix
118 +      --help                    display this help and exit
119 +      --version                 output version information and exit
120 +
121 +The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX.  The
122 +version control may be set with VERSION_CONTROL, values are:
123 +
124 +  numbered, t     make numbered backups
125 +  existing, nil   numbered if numbered backups exist, simple otherwise
126 +  simple, never   always make simple backups
127 +
128 +Report bugs to pederst\@cpan.org
129 +HELP
130 +    exit 0; #'
131 +}
132 +
133 +if ($opt_backup) {
134 +    if ($opt_prefix || $opt_basename_prefix || $opt_suffix) {
135 +        $vcm = VCM_SIMPLE;
136 +    }
137 +    else {
138 +        $vcm = ${abbrev qw(nil existing t numbered never simple)}{$opt_vcm};
139 +        error("invalid version contol type `$opt_vcm'") unless $vcm;
140 +        $vcm = ${{ nil      => VCM_TEST,
141 +                  existing => VCM_TEST,
142 +                  t        => VCM_NUMBERED,
143 +                   numbered => VCM_NUMBERED,
144 +                  never    => VCM_SIMPLE,
145 +                  simple   => VCM_SIMPLE,
146 +               }}{$vcm};
147 +    }
148 +
149 +    $opt_suffix ||= $ENV{SIMPLE_BACKUP_SUFFIX} || '~';
150 +}
151 +
152 +my $op = shift
153 +    or error('missing arguments');
154 +
155 +if (!@ARGV) {
156 +    if ($opt_stdin) {
157 +        @ARGV = <STDIN>;
158 +        chomp(@ARGV);
159 +    }
160 +    else {
161 +       exit;
162 +    }
163 +}
164 +
165 +for (@ARGV) {
166 +    my $was = $_;
167 +    {
168 +        no strict;
169 +        eval $op;
170 +    }
171 +    die $@ if $@;
172 +    next if $was eq $_;
173 +
174 +    if (-e $_) {
175 +        unless ($opt_force) {
176 +           if (! -w && -t) {
177 +               printf "%s: overwrite `%s', overriding mode 0%03o? ",
178 +                       $ME, $_, (stat _)[2]&0777;
179 +               next unless <STDIN> =~ /^y/i;
180 +           }
181 +            elsif ($opt_interactive) {
182 +               print "$ME: replace `$_'? ";
183 +               next unless <STDIN> =~ /^y/i;
184 +           }
185 +       }
186 +       if ($opt_backup) {
187 +            my $old;
188 +           if ($vcm == VCM_SIMPLE) {
189 +                if (m,^(.*/)?(.*),) {
190 +                   $old = "$opt_prefix$1$opt_basename_prefix$2$opt_suffix";
191 +                }
192 +           }
193 +            else {
194 +               ($old) = sort {($b=~/~(\d+)~$/)[0] <=> ($a=~/~(\d+)~$/)[0]} bsd_glob "$_.~*~";
195 +               $old =~ s/~(\d+)~$/'~'.($1+1).'~'/e;
196 +               if ($vcm == VCM_TEST) {
197 +                    unless ($old) {
198 +                        if (m,^(.*/)?(.*),) {
199 +                           $old = "$opt_prefix$1$opt_basename_prefix$2$opt_suffix";
200 +                        }
201 +                    }
202 +               }
203 +                elsif ($vcm == VCM_NUMBERED) {
204 +                   $old ||= "$_.~1~";
205 +               }
206 +           }
207 +            print "backup: $_ -> $old\n" if $opt_verbose && $opt_dryrun;
208 +
209 +            unless ($opt_dryrun) {
210 +                if ($old =~ m,/,) {
211 +                    my $dir = File::Basename::dirname($old);
212 +                    unless (-d $dir) {
213 +                        if ($opt_dryrun) {
214 +                            print "mkdir: $dir\n" if $opt_verbose;
215 +                        }
216 +                        else {
217 +                            mkpath($dir) || next;
218 +                        }
219 +                    }
220 +                }
221 +                unless (rename($_,$old)) {
222 +                    warn "$ME: cannot create `$old': $!\n";
223 +                    next;
224 +                }
225 +            }
226 +        }
227 +    }
228 +
229 +    print "$was ", $opt_linkonly ? "=" : '-', "> $_\n"
230 +       if $opt_verbose || $opt_dryrun;
231 +
232 +    if (m,/,) {
233 +        my $dir = File::Basename::dirname($_);
234 +        unless (-d $dir) {
235 +            if ($opt_dryrun) {
236 +                print "mkdir: $dir\n" if $opt_verbose;
237 +            }
238 +            else {
239 +                mkpath($dir) || next;
240 +            }
241 +         }
242 +    }
243 +
244 +    unless ($opt_dryrun) {
245 +        if ($opt_linkonly) {
246 +           link($was,$_) || warn "$ME: cannot create `$_': $!\n";
247 +        }
248 +        else {
249 +            rename($was,$_) || warn "$ME: cannot create `$_': $!\n";
250 +       }
251 +    }
252 +}
253 +
254 +sub mkpath {
255 +    my($path) = @_;
256 +    $path .= '/' if $^O eq 'os2' and $path =~ /^\w:\z/s; # feature of CRT 
257 +    # Logic wants Unix paths, so go with the flow.
258 +    if ($^O eq 'VMS') {
259 +        next if $path eq '/';
260 +        $path = VMS::Filespec::unixify($path);
261 +        if ($path =~ m:^(/[^/]+)/?\z:) {
262 +            $path = $1.'/000000';
263 +        }
264 +    }
265 +    return 1 if -d $path;
266 +    my $parent = File::Basename::dirname($path);
267 +    unless (-d $parent or $path eq $parent) {
268 +        mkpath($parent) || return;
269 +    }
270 +    #print "mkdir: $path\n" if $opt_verbose;
271 +    unless (mkdir($path, 0777)) {
272 +        unless (-d $path) {
273 +            warn "$ME: cannot mkdir `$path': $!\n";
274 +            return;
275 +        }
276 +    }
277 +    return 1;
278 +}
279 +
280 +__END__
281 +
282 +=head1 NAME
283 +
284 +prename - renames multiple files
285 +
286 +=head1 SYNOPSIS
287 +
288 +B<prename>
289 +[B<-bfilnv>]
290 +[B<-B> I<prefix>]
291 +[B<-S> I<suffix>]
292 +[B<-V> I<method>]
293 +[B<-Y> I<prefix>]
294 +[B<-z> I<suffix>]
295 +[B<--backup>]
296 +[B<--basename-prefix=>I<prefix>]
297 +[B<--dry-run>]
298 +[B<--force>]
299 +[B<--help>]
300 +[B<--no-stdin>]
301 +[B<--interactive>]
302 +[B<--just-print>]
303 +[B<--link-only>]
304 +[B<--prefix=>I<prefix>]
305 +[B<--suffix=>I<suffix>]
306 +[B<--verbose>]
307 +[B<--version-control=>I<method>]
308 +[B<--version>]
309 +I<perlexpr>
310 +[F<files>]...
311 +
312 +=head1 DESCRIPTION
313 +
314 +I<prename> renames the filenames supplied according to the rule specified
315 +as the first argument.  The argument is a Perl expression which is
316 +expected to modify the $_ string for at least some of the filenames
317 +specified.  If a given filename is not modified by the expression, it
318 +will not be renamed.  If no filenames are given on the command line,
319 +filenames will be read via standard input.
320 +
321 +If a destination file is unwritable, the standard input is a tty, and
322 +the B<-f> or B<--force> option is not given, mv prompts the user for
323 +whether to overwrite the file.  If the response does not begin with `y'
324 +or `Y', the file is skipped.
325 +
326 +=head1 OPTIONS
327 +
328 +=over 4
329 +
330 +=item B<-b>, B<--backup>
331 +
332 +Make backup files.  That is, when about to overwrite a file, rename the
333 +original instead of removing it.  See the B<-V> or B<--version-control>
334 +option fo details about how backup file names are determined.
335 +
336 +=item B<-B> I<prefix>, B<--prefix=>I<prefix>
337 +
338 +Use the B<simple> method to determine backup file names (see the B<-V>
339 +I<method> or B<--version-control=>I<method> option), and prepend
340 +I<prefix> to a file name when generating its backup file name.
341 +
342 +=item B<-f>, B<--force>
343 +
344 +Remove existing destination files and never prompt the user.
345 +
346 +=item B<-h>, B<--help>
347 +
348 +Print a summary of options and exit.
349 +
350 +=item B<-no-stdin>
351 +
352 +Disable reading of filenames from STDIN. Us it when your shell has nullglob
353 +enabled to make sure prename doesn't wait for input.
354 +
355 +=item B<-i>, B<--interactive>
356 +
357 +Prompt whether to overwrite each destination file that already exists.
358 +If the response does not begin with `y' or `Y', the file is skipped.
359 +
360 +=item B<-l>, B<--link-only>
361 +
362 +Link files to the new names instead of renaming them. This will keep the
363 +original files.
364 +
365 +=item B<-n>, B<--just-print>, B<--dry-run>
366 +
367 +Do everything but the actual renaming, insted just print the name of
368 +each file that would be renamed. When used together with B<--verbose>,
369 +also print names of backups (which may or may not be correct depending
370 +on previous renaming).
371 +
372 +=item B<-v>, B<--verbose>
373 +
374 +Print the name of each file before renaming it.
375 +
376 +=item B<-V> I<method>, B<--version-control=>I<method>
377 +
378 +Use I<method> to determine backup file names.  The method can also be
379 +given by the B<RENAME_VERSION_CONTROL> (or if that's not set, the
380 +B<VERSION_CONTROL>) environment variable, which is overridden by this
381 +option.  This option does not affect wheter backup files are made; it
382 +affects only the name of any backup files that are made.
383 +
384 +The value of I<method> is like the GNU Emacs `version-control' variable;
385 +B<prename> also recognize synonyms that are more descriptive.  The valid
386 +values are (unique abbreviations are accepted):
387 +
388 +=over
389 +
390 +=item B<existing> or B<nil>
391 +
392 +Make numbered backups of files that already have them, otherwise simple
393 +backups. This is the default.
394 +
395 +=item B<numbered> or B<t>
396 +
397 +Make numbered backups.  The numbered backup file name for I<F> is
398 +B<I<F>.~I<N>~> where I<N> is the version number.
399 +
400 +=item B<simple> or B<never>
401 +
402 +Make simple backups.  The B<-B> or B<--prefix>, B<-Y> or
403 +B<--basename-prefix>, and B<-z> or B<--suffix> options specify the
404 +simple backup file name.  If none of these options are given, then a
405 +simple backup suffix is used, either the value of
406 +B<SIMPLE_BACKUP_SUFFIX> environment variable if set, or B<~> otherwise.
407 +
408 +=back
409 +
410 +=item B<--version>
411 +
412 +Print version information on standard output then exit successfully.
413 +
414 +=item B<-Y> I<prefix>, B<--basename-prefix=>I<prefix>
415 +
416 +Use the B<simple> method to determine backup file names (see the B<-V>
417 +I<method> or B<--version-control=>I<method> option), and prefix
418 +I<prefix> to the basename of a file name when generating its backup file
419 +name. For example, with B<-Y .del/> the simple backup file name for
420 +B<a/b/foo> is B<a/b/.del/foo>.
421 +
422 +=item B<-z> I<suffix>, B<-S> I<suffix>, B<--suffix=>I<suffix>
423 +
424 +Use the B<simple> method to determine backup file names (see the B<-V>
425 +I<method> or B<--version-control=>I<method> option), and append
426 +I<suffix> to a file name when generating its backup file name.
427 +
428 +=back
429 +
430 +=head1 EXAMPLES
431 +
432 +To rename all files matching *.bak to strip the extension, you might
433 +say
434 +
435 +    prename 's/\e.bak$//' *.bak
436 +
437 +To translate uppercase names to lower, you'd use
438 +
439 +    prename 'y/A-Z/a-z/' *
440 +
441 +More examples:
442 +
443 +    prename 's/\.flip$/.flop/'       # rename *.flip to *.flop
444 +    prename s/flip/flop/             # rename *flip* to *flop*
445 +    prename 's/^s\.(.*)/$1.X/'       # switch sccs filenames around
446 +    prename 's/$/.orig/ */*.[ch]'    # add .orig to source files in */
447 +    prename 'y/A-Z/a-z/'             # lowercase all filenames in .
448 +    prename 'y/A-Z/a-z/ if -B'       # same, but just binaries!
449 +or even
450 +    prename chop *~                  # restore all ~ backup files
451 +
452 +=head1 ENVIRONMENT
453 +
454 +Two environment variables are used, B<SIMPLE_BACKUP_SUFFIX> and
455 +B<VERSION_CONTROL>.  See L</OPTIONS>.
456 +
457 +=head1 SEE ALSO
458 +
459 +mv(1) and perl(1)
460 +
461 +=head1 DIAGNOSTICS
462 +
463 +If you give an invalid Perl expression you'll get a syntax error.
464 +
465 +=head1 AUTHOR
466 +
467 +Peder Stray <pederst@cpan.org>, original script from Larry Wall.
468 +
469 +=cut
470 +!NO!SUBST!
471 diff -up rename-1.9/bin/rename.PL.namechange rename-1.9/bin/rename.PL
472 --- rename-1.9/bin/rename.PL.namechange 2016-10-17 17:31:18.134255013 +0200
473 +++ rename-1.9/bin/rename.PL    2016-10-17 17:32:28.366669129 +0200
474 @@ -1,466 +0,0 @@
475 -use Config;
476 -use File::Basename qw(basename dirname);
477 -
478 -($VERSION)=' $Id: rename.PL,v 1.9 Exp $ '=~/v\s*(\d+(?:\.\d+)+)/;
479 -
480 -chdir(dirname($0));
481 -($file = basename($0)) =~ s/\.PL$//;
482 -$file =~ s/\.pl$//
483 -        if ($Config{'osname'} eq 'VMS' or
484 -            $Config{'osname'} eq 'OS2');  # "case-forgiving"
485 -open OUT,">$file" or die "Can't create $file: $!";
486 -chmod(0755, $file);
487 -print "Extracting $file\n";
488 -
489 -print OUT <<"!DO!SUBST!";
490 -$Config{'startperl'}
491 -
492 -#line 18
493 -
494 -use strict;
495 -
496 -use Getopt::Long;
497 -use Text::Abbrev;
498 -use File::Basename;
499 -use File::Glob ':bsd_glob';
500 -
501 -my \$VERSION = '$VERSION';
502 -
503 -!DO!SUBST!
504 -
505 -print OUT<<'!NO!SUBST!';
506 -Getopt::Long::config(qw(bundling));
507 -$Getopt::Long::prefix = '--';
508 -
509 -my $ME = $0;
510 -($ME = $0) =~ s!.*/!!;
511 -$| = 1;
512 -
513 -my $opt_dryrun          = 0;
514 -my $opt_backup          = 0;
515 -my $opt_force           = 0;
516 -my $opt_interactive     = 0;
517 -my $opt_verbose         = 0;
518 -my $opt_help            = 0;
519 -my $opt_stdin           = 1;
520 -my $opt_version         = 0;
521 -my $opt_linkonly        = 0;
522 -my $opt_prefix          = '';
523 -my $opt_suffix          = '';
524 -my $opt_basename_prefix = '';
525 -my $opt_vcm             = $ENV{RENAME_VERSION_CONTROL}
526 -                        || $ENV{VERSION_CONTROL}
527 -                        || 'existing';
528 -
529 -sub VCM_SIMPLE   { 0 }
530 -sub VCM_TEST     { 1 }
531 -sub VCM_NUMBERED { 2 }
532 -
533 -my $vcm;
534 -
535 -sub error {
536 -    my($ERROR) = @_;
537 -    print "$ME: $ERROR\n";
538 -    print "Try `$ME --help' for more information.\n";
539 -    exit 1;
540 -}
541 -
542 -{
543 -    local $SIG{__WARN__} = sub {
544 -       if ($_[0] =~ /^Unknown option: (\S+)/) {
545 -           error("unrecognized option `--$1'");
546 -       }
547 -        else {
548 -           print @_;
549 -       }
550 -    };
551 -    GetOptions(
552 -              'b|backup'             => \$opt_backup,
553 -               'B|prefix=s'           => \$opt_prefix,
554 -              'f|force'              => \$opt_force,
555 -              'h|help'               => \$opt_help,
556 -              'i|interactive'        => \$opt_interactive,
557 -               'l|link-only'          => \$opt_linkonly,
558 -              'n|just-print|dry-run' => \$opt_dryrun,
559 -               's|stdin!'             => \$opt_stdin,
560 -              'version'              => \$opt_version,
561 -              'v|verbose'            => \$opt_verbose,
562 -              'V|version-control=s'  => \$opt_vcm,
563 -               'Y|basename-prefix=s'  => \$opt_basename_prefix,
564 -              'z|S|suffix=s'         => \$opt_suffix,
565 -             );
566 -}
567 -
568 -if ($opt_version) {
569 -    print "$ME $VERSION\n";
570 -    exit 0;
571 -}
572 -
573 -if ($opt_help) {
574 -    print<<HELP;
575 -Usage: $ME [OPTION]... PERLEXPR FILE...
576 -Rename FILE(s) using PERLEXPR on each filename.
577 -
578 -  -b, --backup                  make backup before removal
579 -  -B, --prefix=SUFFIX           set backup filename prefix
580 -  -f, --force                   remove existing destinations, never prompt
581 -  -i, --interactive             prompt before overwrite
582 -  -l, --link-only               link file instead of reame
583 -  -n, --just-print, --dry-run   don't rename, implies --verbose
584 -  -v, --verbose                 explain what is being done
585 -  -V, --version-control=METHOD  override the usual version control
586 -  -Y, --basename-prefix=PREFIX  set backup filename basename prefix
587 -  -z, -S, --suffix=SUFFIX       set backup filename suffix
588 -      --help                    display this help and exit
589 -      --version                 output version information and exit
590 -
591 -The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX.  The
592 -version control may be set with VERSION_CONTROL, values are:
593 -
594 -  numbered, t     make numbered backups
595 -  existing, nil   numbered if numbered backups exist, simple otherwise
596 -  simple, never   always make simple backups
597 -
598 -Report bugs to pederst\@cpan.org
599 -HELP
600 -    exit 0; #'
601 -}
602 -
603 -if ($opt_backup) {
604 -    if ($opt_prefix || $opt_basename_prefix || $opt_suffix) {
605 -        $vcm = VCM_SIMPLE;
606 -    }
607 -    else {
608 -        $vcm = ${abbrev qw(nil existing t numbered never simple)}{$opt_vcm};
609 -        error("invalid version contol type `$opt_vcm'") unless $vcm;
610 -        $vcm = ${{ nil      => VCM_TEST,
611 -                  existing => VCM_TEST,
612 -                  t        => VCM_NUMBERED,
613 -                   numbered => VCM_NUMBERED,
614 -                  never    => VCM_SIMPLE,
615 -                  simple   => VCM_SIMPLE,
616 -               }}{$vcm};
617 -    }
618 -
619 -    $opt_suffix ||= $ENV{SIMPLE_BACKUP_SUFFIX} || '~';
620 -}
621 -
622 -my $op = shift
623 -    or error('missing arguments');
624 -
625 -if (!@ARGV) {
626 -    if ($opt_stdin) {
627 -        @ARGV = <STDIN>;
628 -        chomp(@ARGV);
629 -    }
630 -    else {
631 -       exit;
632 -    }
633 -}
634 -
635 -for (@ARGV) {
636 -    my $was = $_;
637 -    {
638 -        no strict;
639 -        eval $op;
640 -    }
641 -    die $@ if $@;
642 -    next if $was eq $_;
643 -
644 -    if (-e $_) {
645 -        unless ($opt_force) {
646 -           if (! -w && -t) {
647 -               printf "%s: overwrite `%s', overriding mode 0%03o? ",
648 -                       $ME, $_, (stat _)[2]&0777;
649 -               next unless <STDIN> =~ /^y/i;
650 -           }
651 -            elsif ($opt_interactive) {
652 -               print "$ME: replace `$_'? ";
653 -               next unless <STDIN> =~ /^y/i;
654 -           }
655 -       }
656 -       if ($opt_backup) {
657 -            my $old;
658 -           if ($vcm == VCM_SIMPLE) {
659 -                if (m,^(.*/)?(.*),) {
660 -                   $old = "$opt_prefix$1$opt_basename_prefix$2$opt_suffix";
661 -                }
662 -           }
663 -            else {
664 -               ($old) = sort {($b=~/~(\d+)~$/)[0] <=> ($a=~/~(\d+)~$/)[0]} bsd_glob "$_.~*~";
665 -               $old =~ s/~(\d+)~$/'~'.($1+1).'~'/e;
666 -               if ($vcm == VCM_TEST) {
667 -                    unless ($old) {
668 -                        if (m,^(.*/)?(.*),) {
669 -                           $old = "$opt_prefix$1$opt_basename_prefix$2$opt_suffix";
670 -                        }
671 -                    }
672 -               }
673 -                elsif ($vcm == VCM_NUMBERED) {
674 -                   $old ||= "$_.~1~";
675 -               }
676 -           }
677 -            print "backup: $_ -> $old\n" if $opt_verbose && $opt_dryrun;
678 -
679 -            unless ($opt_dryrun) {
680 -                if ($old =~ m,/,) {
681 -                    my $dir = File::Basename::dirname($old);
682 -                    unless (-d $dir) {
683 -                        if ($opt_dryrun) {
684 -                            print "mkdir: $dir\n" if $opt_verbose;
685 -                        }
686 -                        else {
687 -                            mkpath($dir) || next;
688 -                        }
689 -                    }
690 -                }
691 -                unless (rename($_,$old)) {
692 -                    warn "$ME: cannot create `$old': $!\n";
693 -                    next;
694 -                }
695 -            }
696 -        }
697 -    }
698 -
699 -    print "$was ", $opt_linkonly ? "=" : '-', "> $_\n"
700 -       if $opt_verbose || $opt_dryrun;
701 -
702 -    if (m,/,) {
703 -        my $dir = File::Basename::dirname($_);
704 -        unless (-d $dir) {
705 -            if ($opt_dryrun) {
706 -                print "mkdir: $dir\n" if $opt_verbose;
707 -            }
708 -            else {
709 -                mkpath($dir) || next;
710 -            }
711 -         }
712 -    }
713 -
714 -    unless ($opt_dryrun) {
715 -        if ($opt_linkonly) {
716 -           link($was,$_) || warn "$ME: cannot create `$_': $!\n";
717 -        }
718 -        else {
719 -            rename($was,$_) || warn "$ME: cannot create `$_': $!\n";
720 -       }
721 -    }
722 -}
723 -
724 -sub mkpath {
725 -    my($path) = @_;
726 -    $path .= '/' if $^O eq 'os2' and $path =~ /^\w:\z/s; # feature of CRT 
727 -    # Logic wants Unix paths, so go with the flow.
728 -    if ($^O eq 'VMS') {
729 -        next if $path eq '/';
730 -        $path = VMS::Filespec::unixify($path);
731 -        if ($path =~ m:^(/[^/]+)/?\z:) {
732 -            $path = $1.'/000000';
733 -        }
734 -    }
735 -    return 1 if -d $path;
736 -    my $parent = File::Basename::dirname($path);
737 -    unless (-d $parent or $path eq $parent) {
738 -        mkpath($parent) || return;
739 -    }
740 -    #print "mkdir: $path\n" if $opt_verbose;
741 -    unless (mkdir($path, 0777)) {
742 -        unless (-d $path) {
743 -            warn "$ME: cannot mkdir `$path': $!\n";
744 -            return;
745 -        }
746 -    }
747 -    return 1;
748 -}
749 -
750 -__END__
751 -
752 -=head1 NAME
753 -
754 -rename - renames multiple files
755 -
756 -=head1 SYNOPSIS
757 -
758 -B<rename>
759 -[B<-bfilnv>]
760 -[B<-B> I<prefix>]
761 -[B<-S> I<suffix>]
762 -[B<-V> I<method>]
763 -[B<-Y> I<prefix>]
764 -[B<-z> I<suffix>]
765 -[B<--backup>]
766 -[B<--basename-prefix=>I<prefix>]
767 -[B<--dry-run>]
768 -[B<--force>]
769 -[B<--help>]
770 -[B<--no-stdin>]
771 -[B<--interactive>]
772 -[B<--just-print>]
773 -[B<--link-only>]
774 -[B<--prefix=>I<prefix>]
775 -[B<--suffix=>I<suffix>]
776 -[B<--verbose>]
777 -[B<--version-control=>I<method>]
778 -[B<--version>]
779 -I<perlexpr>
780 -[F<files>]...
781 -
782 -=head1 DESCRIPTION
783 -
784 -I<rename> renames the filenames supplied according to the rule specified
785 -as the first argument.  The argument is a Perl expression which is
786 -expected to modify the $_ string for at least some of the filenames
787 -specified.  If a given filename is not modified by the expression, it
788 -will not be renamed.  If no filenames are given on the command line,
789 -filenames will be read via standard input.
790 -
791 -If a destination file is unwritable, the standard input is a tty, and
792 -the B<-f> or B<--force> option is not given, mv prompts the user for
793 -whether to overwrite the file.  If the response does not begin with `y'
794 -or `Y', the file is skipped.
795 -
796 -=head1 OPTIONS
797 -
798 -=over 4
799 -
800 -=item B<-b>, B<--backup>
801 -
802 -Make backup files.  That is, when about to overwrite a file, rename the
803 -original instead of removing it.  See the B<-V> or B<--version-control>
804 -option fo details about how backup file names are determined.
805 -
806 -=item B<-B> I<prefix>, B<--prefix=>I<prefix>
807 -
808 -Use the B<simple> method to determine backup file names (see the B<-V>
809 -I<method> or B<--version-control=>I<method> option), and prepend
810 -I<prefix> to a file name when generating its backup file name.
811 -
812 -=item B<-f>, B<--force>
813 -
814 -Remove existing destination files and never prompt the user.
815 -
816 -=item B<-h>, B<--help>
817 -
818 -Print a summary of options and exit.
819 -
820 -=item B<-no-stdin>
821 -
822 -Disable reading of filenames from STDIN. Us it when your shell has nullglob
823 -enabled to make sure rename doesn't wait for input.
824 -
825 -=item B<-i>, B<--interactive>
826 -
827 -Prompt whether to overwrite each destination file that already exists.
828 -If the response does not begin with `y' or `Y', the file is skipped.
829 -
830 -=item B<-l>, B<--link-only>
831 -
832 -Link files to the new names instead of renaming them. This will keep the
833 -original files.
834 -
835 -=item B<-n>, B<--just-print>, B<--dry-run>
836 -
837 -Do everything but the actual renaming, insted just print the name of
838 -each file that would be renamed. When used together with B<--verbose>,
839 -also print names of backups (which may or may not be correct depending
840 -on previous renaming).
841 -
842 -=item B<-v>, B<--verbose>
843 -
844 -Print the name of each file before renaming it.
845 -
846 -=item B<-V> I<method>, B<--version-control=>I<method>
847 -
848 -Use I<method> to determine backup file names.  The method can also be
849 -given by the B<RENAME_VERSION_CONTROL> (or if that's not set, the
850 -B<VERSION_CONTROL>) environment variable, which is overridden by this
851 -option.  This option does not affect wheter backup files are made; it
852 -affects only the name of any backup files that are made.
853 -
854 -The value of I<method> is like the GNU Emacs `version-control' variable;
855 -B<rename> also recognize synonyms that are more descriptive.  The valid
856 -values are (unique abbreviations are accepted):
857 -
858 -=over
859 -
860 -=item B<existing> or B<nil>
861 -
862 -Make numbered backups of files that already have them, otherwise simple
863 -backups. This is the default.
864 -
865 -=item B<numbered> or B<t>
866 -
867 -Make numbered backups.  The numbered backup file name for I<F> is
868 -B<I<F>.~I<N>~> where I<N> is the version number.
869 -
870 -=item B<simple> or B<never>
871 -
872 -Make simple backups.  The B<-B> or B<--prefix>, B<-Y> or
873 -B<--basename-prefix>, and B<-z> or B<--suffix> options specify the
874 -simple backup file name.  If none of these options are given, then a
875 -simple backup suffix is used, either the value of
876 -B<SIMPLE_BACKUP_SUFFIX> environment variable if set, or B<~> otherwise.
877 -
878 -=back
879 -
880 -=item B<--version>
881 -
882 -Print version information on standard output then exit successfully.
883 -
884 -=item B<-Y> I<prefix>, B<--basename-prefix=>I<prefix>
885 -
886 -Use the B<simple> method to determine backup file names (see the B<-V>
887 -I<method> or B<--version-control=>I<method> option), and prefix
888 -I<prefix> to the basename of a file name when generating its backup file
889 -name. For example, with B<-Y .del/> the simple backup file name for
890 -B<a/b/foo> is B<a/b/.del/foo>.
891 -
892 -=item B<-z> I<suffix>, B<-S> I<suffix>, B<--suffix=>I<suffix>
893 -
894 -Use the B<simple> method to determine backup file names (see the B<-V>
895 -I<method> or B<--version-control=>I<method> option), and append
896 -I<suffix> to a file name when generating its backup file name.
897 -
898 -=back
899 -
900 -=head1 EXAMPLES
901 -
902 -To rename all files matching *.bak to strip the extension, you might
903 -say
904 -
905 -    rename 's/\e.bak$//' *.bak
906 -
907 -To translate uppercase names to lower, you'd use
908 -
909 -    rename 'y/A-Z/a-z/' *
910 -
911 -More examples:
912 -
913 -    rename 's/\.flip$/.flop/'       # rename *.flip to *.flop
914 -    rename s/flip/flop/             # rename *flip* to *flop*
915 -    rename 's/^s\.(.*)/$1.X/'       # switch sccs filenames around
916 -    rename 's/$/.orig/ */*.[ch]'    # add .orig to source files in */
917 -    rename 'y/A-Z/a-z/'             # lowercase all filenames in .
918 -    rename 'y/A-Z/a-z/ if -B'       # same, but just binaries!
919 -or even
920 -    rename chop *~                  # restore all ~ backup files
921 -
922 -=head1 ENVIRONMENT
923 -
924 -Two environment variables are used, B<SIMPLE_BACKUP_SUFFIX> and
925 -B<VERSION_CONTROL>.  See L</OPTIONS>.
926 -
927 -=head1 SEE ALSO
928 -
929 -mv(1) and perl(1)
930 -
931 -=head1 DIAGNOSTICS
932 -
933 -If you give an invalid Perl expression you'll get a syntax error.
934 -
935 -=head1 AUTHOR
936 -
937 -Peder Stray <pederst@cpan.org>, original script from Larry Wall.
938 -
939 -=cut
940 -!NO!SUBST!
941 diff -up rename-1.9/Makefile.PL.namechange rename-1.9/Makefile.PL
942 --- rename-1.9/Makefile.PL.namechange   2016-10-17 17:30:52.944106480 +0200
943 +++ rename-1.9/Makefile.PL      2016-10-17 17:32:09.803559674 +0200
944 @@ -1,9 +1,9 @@
945  use ExtUtils::MakeMaker;
946   
947  WriteMakefile(
948 -              'NAME' => 'rename',
949 -              'VERSION_FROM' => 'bin/rename.PL',
950 -              'PL_FILES' => { "bin/rename.PL" => "bin/rename" },
951 -              'EXE_FILES' => [ "bin/rename" ],
952 +              'NAME' => 'prename',
953 +              'VERSION_FROM' => 'bin/prename.PL',
954 +              'PL_FILES' => { "bin/prename.PL" => "bin/prename" },
955 +              'EXE_FILES' => [ "bin/prename" ],
956                'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
957  );
This page took 0.928559 seconds and 3 git commands to generate.