On Fri Mar 02 09:14:59 2012, HMBRAND wrote:
Show quoted text> GNU tar supports
>
> $ tar -T index -c -f /tmp/xx.tar
>
> ptar only supports that through
>
> $ ptar -c -f /tmp/xx.tar `cat index`
>
> Shouldn't be too hard to add. (Low priority wishlist item)
The patch is actually rather simple and straightforward:
--8<--- add-T.diff (also attached)
--- /pro/bin/ptar.org 2012-03-02 15:15:22.044887937 +0100
+++ /pro/bin/ptar 2012-03-02 15:22:36.497868568 +0100
@@ -10,7 +10,7 @@ use Archive::Tar;
use Data::Dumper;
my $opts = {};
-getopts('Ddcvzthxf:IC', $opts) or die usage();
+getopts('Ddcvzthxf:ICT:', $opts) or die usage();
### show the help message ###
die usage() if $opts->{h};
@@ -31,11 +31,21 @@ my $verbose = $opts->{v} ? 1 : 0;
my $file = $opts->{f} ? $opts->{f} : 'default.tar';
my $tar = Archive::Tar->new();
-
if( $opts->{c} ) {
my @files;
+ my @src = @ARGV;
+ if( $opts->{T} ) {
+ if( $opts->{T} eq "-" ) {
+ chomp( @src = <STDIN> );
+ } elsif( open my $fh, "<", $opts->{T} ) {
+ chomp( @src = <$fh> );
+ } else {
+ die "$0: $opts->{T}: $!\n";
+ }
+ }
+
find( sub { push @files, $File::Find::name;
- print $File::Find::name.$/ if $verbose }, @ARGV );
+ print $File::Find::name.$/ if $verbose }, @src );
if ($file eq '-') {
use IO::Handle;
-->8---