Bug 664937

Summary: zypper search doesn't allow searching for a leading "-"
Product: [openSUSE] openSUSE 11.3 Reporter: Dave Plater <davejplater>
Component: InstallationAssignee: E-mail List <zypp-maintainers>
Status: RESOLVED INVALID QA Contact: Jiri Srain <jsrain>
Severity: Normal    
Priority: P5 - None    
Version: Final   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Dave Plater 2011-01-17 11:24:13 UTC
I wanted to search for all packages that ended in -ruby (checking for the correct groups for language bindings) with the following results :
1.# zypper se -ruby
  Repository 'uby' not found by its alias, number, or URI.
  Use 'zypper repos' to get the list of defined repositories.
Former is an expected result and not a bug the next ones are.

2.# zypper se "-ruby"
  Repository 'uby' not found by its alias, number, or URI.
  Use 'zypper repos' to get the list of defined repositories.
Maybe weak quotes aren't enough but the next two should definitely give me the required result.
3. # zypper se '-ruby'
   Repository 'uby' not found by its alias, number, or URI.
   Use 'zypper repos' to get the list of defined repositories.
4.# zypper se \-ruby
  Repository 'uby' not found by its alias, number, or URI.
  Use 'zypper repos' to get the list of defined repositories.
While writing this bug I thought of using "--" which is used to extra pass arguments to macros etc. and it works.
5.# zypper se -- -ruby
Loading repository data...
Reading installed packages...

S | Name                            | Summary                                                      | Type      
--+---------------------------------+--------------------------------------------------------------+-----------
  | cmpi-bindings-ruby              | Adapter to write and run CMPI-type CIM providers in Ruby     | package   
  | cmpi-bindings-ruby-debuginfo    | Debug information for package cmpi-bindings-ruby             | package   
  | graphviz-ruby                   | Ruby Extension for Graphviz                                  | package   
  | graphviz-ruby-debuginfo         | Debug information for package graphviz-ruby                  | package   
i | kdebindings3-ruby               | Ruby Bindings for Qt and KDE Libraries                       | package   
i | kdebindings3-ruby-debuginfo     | Debug information for package kdebindings3-ruby              | package   
  | koffice-ruby                    | Ruby support and scripts for KOffice scripting               | package   
  | koffice-ruby-debuginfo          | Debug information for package koffice-ruby                   | package   
  | libcaca-ruby                    | Ruby bindings for libcaca                                    | package   
  | libcaca-ruby-debuginfo          | Debug information for package libcaca-ruby                   | package   
  | libcaca0-ruby                   | Ruby bindings package for libcaca                            | package   
  | libcaca0-ruby-debuginfo         | Debug information for package libcaca0-ruby                  | package   
  | openwsman-ruby                  | Ruby bindings for openwsman client API                       | package   
  | openwsman-ruby-debuginfo        | Debug information for package openwsman-ruby                 | package   
  | redland-ruby                    | Perl bindings for programs that use Redland                  | package   
i | redland-ruby-debuginfo          | Debug information for package redland-ruby                   | package   
  | rubygem-libxml-ruby             | Ruby language bindings for the GNOME Libxml2 XML toolkit     | package   
  | rubygem-libxml-ruby             | Ruby language bindings for the GNOME Libxml2 XML toolkit     | srcpackage
  | subversion-ruby                 | Allows Ruby scripts to directly use Subversion repositories. | package   
  | subversion-ruby-debuginfo       | Debug information for package subversion-ruby                | package   
  | xmms2-ruby                      | Ruby support for XMMS2                                       | package   
  | xmms2-ruby-debuginfo            | Debug information for package xmms2-ruby                     | package   
  | yast2-ruby-bindings             | Ruby bindings for the YaST platform                          | package   
  | yast2-ruby-bindings-debuginfo   | Debug information for package yast2-ruby-bindings            | package   
  | yast2-ruby-bindings-debugsource | Debug sources for package yast2-ruby-bindings                | package 

zypper honors weak quotes ("") used with "install", I would have at least expected zypper to honor the escape "\" and there isn't a reason why both types of quotes shouldn't work either.

At least an explanation in the --help output from the affected functions that "--" should be used if the search term has a leading "-"
Comment 1 Jan Kupec 2011-01-20 14:45:40 UTC
Hi Dave, this is actually standard unix command line behavior. Try e.g.

$ ls "-ltr"
$ ls \-ltr
$ ls -- -ltr

As for the quotes and escaping, that's actually the shell's doing, not zypper's.

I don't think it's worth mentioning in the man page or help text. My first encounter with this was when i created a file with a hyphen at the start accidentally in a GUI app. Then i wanted to remove it on the command line. Imagine my surprise :O) But explaining this in each man page or help text would not be a good solution. Everyone needs to learn it the hard way IMO.
Comment 2 Dave Plater 2011-01-20 15:00:05 UTC
At least I won't forget the -- anymore, I'd actually seen it in another man page before and of course rpm macros that accept arguments like %cmake_kde4 need it to pass extra arguments.