tags 681752 + patch
quit

This is how I think it should be fixed.
Both "stow --restow emacs" and "stow --restow -- emacs" work now.

This patch is rather simple, perhaps not copyrightable.
Either way, I am not assigning copyright to the FSF.  According
to /usr/share/doc/stow/copyright, the FSF has no copyright on
GNU Stow anyway.

--- /usr/bin/stow	2012-04-14 08:23:45.000000000 +0300
+++ /home/Kalle/any-arch/bin/stow	2012-07-16 13:02:01.000000000 +0300
@@ -473,6 +473,19 @@
     my @pkgs_to_stow   = ();
     my $action = 'stow';
 
+    my $remember_package_action = sub {
+        if ($action eq 'restow') {
+            push @pkgs_to_unstow, $_[0];
+            push @pkgs_to_stow, $_[0];
+        }
+        elsif ($action eq 'unstow') {
+            push @pkgs_to_unstow, $_[0];
+        }
+        else {
+            push @pkgs_to_stow, $_[0];
+        }
+    };
+
     unshift @ARGV, get_config_file_options();
     #$,="\n"; print @ARGV,"\n"; # for debugging rc file
 
@@ -510,21 +523,12 @@
         'R|restow'  => sub { $action = 'restow' },
 
         # Handler for non-option arguments
-        '<>' =>
-        sub {
-            if ($action eq 'restow') {
-                push @pkgs_to_unstow, $_[0];
-                push @pkgs_to_stow, $_[0];
-            }
-            elsif ($action eq 'unstow') {
-                push @pkgs_to_unstow, $_[0];
-            }
-            else {
-                push @pkgs_to_stow, $_[0];
-            }
-        },
+        '<>' => $remember_package_action,
     ) or usage();
 
+    # If GetOptions stopped at "--", process any remaining arguments.
+    $remember_package_action->($_) foreach @ARGV;
+
     usage()   if $options{help};
     version() if $options{version};
 

Attachment: pgpw4yNLw1to5.pgp
Description: PGP signature

Reply via email to