lp ignores silly options; should give error #4261

Closed
michaelrsweet opened this Issue Jan 21, 2013 · 4 comments

Comments

Projects
None yet
1 participant
Collaborator

michaelrsweet commented Jan 21, 2013

Version: 1.6-current
CUPS.org User: odyx

This bug was reported on the Debian bug tracker and I think it is a valid one:

http://bugs.debian.org/698615

Le lundi, 21 janvier 2013 07.37:17, Trent W. Buck a écrit :

While dealing with an unrelated issue, I tried to type

date | lp -n2 -o collate=true

but instead I typed

date | lp -n2 --collate=true

AFAICT, lp silently ignored the bogus option.
I would strongly prefer that it instead gave an error like this,
possibly followed by a help synopsis of valid options.

lp: illegal option -- -

In this case, because I didn't notice the typo, I ended up wasting a
couple of hours trying to debug the pxlmono.ppd that (I thought)
wasn't working as advertised :-(

Collaborator

michaelrsweet commented Jan 21, 2013

CUPS.org User: mike

There is already code in here to display a "bad option" error message, but the code to support "-" by itself (so you can use "-foo" as a filename, e.g. "lp - -foo") appears to be broken, causing this not to be reported.

Moving to 1.6-current.

Collaborator

michaelrsweet commented Jan 21, 2013

CUPS.org User: mike

Rats, that example should have been:

lp -- -foo

(and yes, that is the syntax, straight from System V...)

Collaborator

michaelrsweet commented Jan 21, 2013

CUPS.org User: mike

Fixed in Subversion repository.

Collaborator

michaelrsweet commented Jan 21, 2013

"str4261.patch":

Index: systemv/lp.c

--- systemv/lp.c (revision 10826)
+++ systemv/lp.c (working copy)
@@ -3,7 +3,7 @@
*

  • "lp" command for CUPS.
  • * Copyright 2007-2012 by Apple Inc.
  • * Copyright 2007-2013 by Apple Inc.
  • Copyright 1997-2007 by Easy Software Products.
  • These coded instructions, statements, and computer programs are the
    @@ -489,6 +489,13 @@
    break;
 case '-' : /* Stop processing options */
  •        if (argv[i][2])
    
  •        {
    
  •     _cupsLangPrintf(stderr, _("%s: Error - unknown option \"%s\"."),
    
  •             argv[0], argv[i]);
    
  •     return (1);
    
  •   }
    
    end_options = 1;
    break;

michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment