unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Ricardo Wurmus <rekado@elephly.net>
Cc: 27820@debbugs.gnu.org, Hartmut Goebel <h.goebel@crazy-compilers.com>
Subject: bug#27820: guix package -u: order of argument is significant
Date: Wed, 26 Jul 2017 10:14:02 +0200	[thread overview]
Message-ID: <874ltzbool.fsf@gnu.org> (raw)
In-Reply-To: <87eft46wir.fsf@elephly.net> (Ricardo Wurmus's message of "Tue, 25 Jul 2017 23:23:40 +0200")

Ricardo Wurmus <rekado@elephly.net> skribis:

> Ludovic Courtès <ludo@gnu.org> writes:
>
>> Mark H Weaver <mhw@netris.org> skribis:
>>
>>> I agree that this is quite confusing.  Perhaps we should issue a warning
>>> if the regexp begins with "-".
>>>
>>> Also, perhaps we should *always* require an argument after "-u", even if
>>> "-u" is at the end of the command line, failing otherwise.  Users would
>>> then learn to always pass an argument to "-u", and thus would be less
>>> likely to fall into this trap when adding more options after the "-u".
>>
>> I’m in favor of the former:
>>
>> diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
>> index 8da7a3fd3..b6133b6af 100644
>> --- a/guix/scripts/package.scm
>> +++ b/guix/scripts/package.scm
>> @@ -486,6 +486,11 @@ Install, remove, or upgrade packages in a single transaction.\n"))
>>                               arg-handler))))
>>           (option '(#\u "upgrade") #f #t
>>                   (lambda (opt name arg result arg-handler)
>> +                   (when (string-prefix? "-" arg)
>> +                     (warning (G_ "upgrade regexp '~a' looks like a \
>> +command-line option~%")
>> +                              arg)
>> +                     (warning (G_ "is this intended?~%")))
>>                     (let arg-handler ((arg arg) (result result))
>>                       (values (alist-cons 'upgrade arg
>>                                           ;; Delete any prior "upgrade all"
>>
>> Thoughts?
>
> This seems good to me.  I just wonder if there are legitimate cases
> where a package regexp would look like a command line option.  If that’s
> not the case could we just “unread” the argument and parse it as the
> next option?

I thought about it but in theory “-” is perfectly legitimate, so I
thought we’d rather not try to be smart.  Thoughts?

Ludo’.

  reply	other threads:[~2017-07-26  8:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-25 11:19 bug#27820: guix package -u: order of argument is significant Hartmut Goebel
2017-07-25 19:40 ` Mark H Weaver
2017-07-25 21:11   ` Ludovic Courtès
2017-07-25 21:23     ` Ricardo Wurmus
2017-07-26  8:14       ` Ludovic Courtès [this message]
2017-07-26  8:59         ` Ricardo Wurmus
2017-07-26 17:58           ` Mark H Weaver
2017-07-31 21:07             ` Ludovic Courtès
2017-07-26 20:49           ` Alex Kost
2017-07-26  8:28   ` Hartmut Goebel
2017-07-26  9:03     ` Ricardo Wurmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874ltzbool.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=27820@debbugs.gnu.org \
    --cc=h.goebel@crazy-compilers.com \
    --cc=rekado@elephly.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).