parallel: GetOptionsFromArray is not supported everywhere

This commit is contained in:
Ole Tange 2010-11-15 20:14:27 +01:00
parent d7c87979f9
commit 4ed346760b
2 changed files with 21 additions and 5 deletions

View file

@ -65,6 +65,7 @@ cd /tmp
wget http://ftp.gnu.org/gnu/parallel/parallel-$YYYYMMDD.tar.bz2 wget http://ftp.gnu.org/gnu/parallel/parallel-$YYYYMMDD.tar.bz2
tar xjvf parallel-$YYYYMMDD.tar.bz2 tar xjvf parallel-$YYYYMMDD.tar.bz2
cd parallel-$YYYYMMDD cd parallel-$YYYYMMDD
./configure
make -j && sudo make -j install make -j && sudo make -j install
== Update OpenSUSE build system == == Update OpenSUSE build system ==
@ -104,6 +105,9 @@ http://nd.gd/2j Watch the intro video http://nd.gd/0s
https://savannah.gnu.org/news/?group=parallel https://savannah.gnu.org/news/?group=parallel
cat twitters | parallel -j1 echo @{} You have earlier shown interest in GNU Parallel. \
A new version is out: http://nd.gd/2j '|' ttytter
== Send announce == == Send announce ==
http://groups.google.com/group/comp.unix.shell/post http://groups.google.com/group/comp.unix.shell/post

View file

@ -2466,7 +2466,7 @@ use Symbol qw(gensym);
use IO::File; use IO::File;
use POSIX qw(:sys_wait_h setsid); use POSIX qw(:sys_wait_h setsid);
use File::Temp qw(tempfile tempdir); use File::Temp qw(tempfile tempdir);
use Getopt::Long qw(GetOptionsFromArray); use Getopt::Long;
use strict; use strict;
do_not_reap(); do_not_reap();
@ -2516,15 +2516,22 @@ sub acquire_semaphore {
} }
sub get_options_from_array { sub get_options_from_array {
# Run GetOptionsFromArray on @array # Run GetOptions on @array
# Returns: # Returns:
# true if parsing worked # true if parsing worked
# false if parsing failed # false if parsing failed
# @array is changed # @array is changed
my $array_ref = shift; my $array_ref = shift;
return GetOptionsFromArray # A bit of shuffling of @ARGV needed as GetOptionsFromArray is not
($array_ref, # supported everywhere
"debug|D" => \$::opt_D, my @save_argv;
my $this_is_ARGV = (\@::ARGV == $array_ref);
if(not $this_is_ARGV) {
@save_argv = @::ARGV;
@::ARGV = @{$array_ref};
}
my @retval = GetOptions
("debug|D" => \$::opt_D,
"xargs|m" => \$::opt_m, "xargs|m" => \$::opt_m,
"X" => \$::opt_X, "X" => \$::opt_X,
"v" => \@::opt_v, "v" => \@::opt_v,
@ -2591,6 +2598,11 @@ sub get_options_from_array {
"Y|shebang|hashbang" => \$::opt_shebang, "Y|shebang|hashbang" => \$::opt_shebang,
"skip-first-line" => \$::opt_skip_first_line, "skip-first-line" => \$::opt_skip_first_line,
); );
if(not $this_is_ARGV) {
@{$array_ref} = @::ARGV;
@::ARGV = @save_argv;
}
return @retval;
} }
sub parse_options { sub parse_options {