Bug#681752: "stow --restow -- emacs" claims "stow: No packages to stow or unstow"

July 16th, 2012 - 04:10 am ET by Kalle Olavi Niemitalo | Report spam
Package: stow
Version: 2.2.0-1
Severity: normal

I have a script that configures and builds a package and stows
the resulting binaries. As a precaution against hypothetical
package names that start with a dash, it uses "--" like so:

( cd -- "${stowdir}" && stow --restow -- "${PKG_STOWNAME}" )

This used to work, but now when I try with stow 2.2.0-1, it fails:

| ( cd -- "/home/Kalle/prefix/stow" && stow --restow -- "emacs" )
| stow: No packages to stow or unstow
|
| stow (GNU Stow) version 2.2.0
|
| SYNOPSIS:
|
| stow [OPTION ...] [-D|-S|-R] PACKAGE ... [-D|-S|-R] PACKAGE ...
|
| OPTIONS:
|
| -d DIR, --dir=DIR Set stow dir to DIR (default is current dir)
| -t DIR, --target=DIR Set target to DIR (default is parent of stow dir)
|
| -S, --stow Stow the package names that follow this option
| -D, --delete Unstow the package names that follow this option
| -R, --restow Restow (like stow -D followed by stow -S)
|
| --ignore=REGEX Ignore files ending in this Perl regex
| --defer=REGEX Don't stow files beginning with this Perl regex
| if the file is already stowed to another package
| --override=REGEX Force stowing files beginning with this Perl regex
| if the file is already stowed to another package
| --adopt (Use with care!) Import existing files into stow package
| from target. Please read docs before using.
| -p, --compat Use legacy algorithm for unstowing
|
| -n, --no, --simulate Do not actually make any filesystem changes
| -v, --verbose[=N] Increase verbosity (levels are 0,1,2,3;
| -v or --verbose adds 1; --verbose=N sets level)
| -V, --version Show stow version number
| -h, --help Show this help
|
| Report bugs to: bug-stow@gnu.org
| Stow home page: <http://www.gnu.org/software/stow/>
| General help using GNU software: <http://www.gnu.org/gethelp/>
| make[1]: *** [pkg-stow] Virhe 1

Without "--", it works OK. However, I don't see in the above
command-line synopsis anything that would disallow inserting "--"
there. "--" is supposed to treat all subsequent arguments as
non-options, and package names are not intended to be options,
so "--" should be fine.

I guess the problem is that Stow collects the package names from
the command line by giving a "Handler for non-option arguments"
to Getopt::Long::GetOptions, which stops reading arguments from
@ARGV when it sees "--". Stow should follow the GetOptions call
with a loop that processes any remaining package names from @ARGV.

Debian Release: wheezy/sid
APT prefers testing
APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=fi_FI.utf8, LC_CTYPE=fi_FI.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages stow depends on:
ii dpkg 1.16.4.3
ii install-info 4.13a.dfsg.1-10
ii perl 5.14.2-12

stow recommends no packages.

Versions of packages stow suggests:
ii doc-base 0.10.3





To UNSUBSCRIBE, email to debian-bugs-dist-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
email Follow the discussionReplies 1 replyReplies Make a reply

Similar topics

Replies

#1 Kalle Olavi Niemitalo
July 16th, 2012 - 06:30 am ET | Report spam

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();
#$,=""; print @ARGV,""; # 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};






To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
email Follow the discussion Replies Reply to this message
Help Create a new topicReplies Make a reply
Search Make your own search