Bug 1448609 - Filename shown instead of command name in error message when script used with invalid option
Summary: Filename shown instead of command name in error message when script used with...
Keywords:
Status: POST
Alias: None
Product: LVM and device-mapper
Classification: Community
Component: lvm2
Version: 2.02.171
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: RHEL 7
: 2016-05
Assignee: David Teigland
QA Contact: cluster-qe
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-05-06 00:02 UTC by Alasdair Kergon
Modified: 2023-08-10 15:41 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Embargoed:
rule-engine: lvm-technical-solution?
rule-engine: lvm-test-coverage?


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Gentoo 617578 0 None None None 2017-05-06 00:02:49 UTC

Description Alasdair Kergon 2017-05-06 00:02:49 UTC
The error message should show argv[0] when an unrecognized option is detected when using lvm in script mode.

# ./lvm /dev/null --config fff
/dev/null: unrecognized option '--config'
  Error during parsing of command line.

Comment 1 Alasdair Kergon 2017-05-06 00:06:55 UTC
It also appears to be silently ignoring additional positional arguments, which similarly have no effect and generate an error.

Comment 2 Alasdair Kergon 2017-05-06 00:18:09 UTC
(Whether or not we can easily support --config in that situation is a separate question - I suspect it's not easy or we'd already have done it.)

Comment 3 David Teigland 2017-05-10 18:16:07 UTC
Three commits here fix up the inconsistent handling of invalid commands in command/shell/script

https://sourceware.org/git/?p=lvm2.git;a=shortlog;h=refs/heads/dev-dct-no-such-command-2

Comment 4 Robin H. Johnson 2017-07-09 21:42:29 UTC
@teigland:
That ref seems to be missing now. Did it get merged (there's no merge entries so I can't easily tell without having copies of those commits elsewhere).

Comment 5 David Teigland 2017-07-10 14:06:08 UTC
> That ref seems to be missing now. Did it get merged (there's no merge
> entries so I can't easily tell without having copies of those commits
> elsewhere).

They are in the master branch.  There may be another patch or two related to this.

commit cf3a6bbbe881d9a4ba6d108304f0c07ee6cd8d1a
Author: David Teigland <teigland>
Date:   Mon May 8 10:50:27 2017 -0500

    commands: fix handing of ENO_SUCH_CMD in script
    
    Fix the error messages when an unrecognized command is
    run from a script.  We shouldn't attempt to parse options
    for an unrecognized command name, which causes misleading
    errors about bad options, but rather exit right when we
    know the command name is not valid.  Also don't complain
    about exiting without an error message when running a
    script if no command didn't exist.

commit 85f1814e9dc574c271cfdae91adfe2628ff62fa9
Author: David Teigland <teigland>
Date:   Mon May 8 10:31:30 2017 -0500

    commands: centralize shell vs script vs command decision
    
    This clarifies the point where lvm decides if it is
    running an lvm shell, command or a script.

Comment 6 Robin H. Johnson 2017-07-10 22:41:44 UTC
thanks, so they will be in 2.02.173.


Note You need to log in before you can comment on or make changes to this bug.