Bug 1448609

Summary: Filename shown instead of command name in error message when script used with invalid option
Product: [Community] LVM and device-mapper Reporter: Alasdair Kergon <agk>
Component: lvm2Assignee: David Teigland <teigland>
lvm2 sub component: Other QA Contact: cluster-qe <cluster-qe>
Status: POST --- Docs Contact:
Severity: low    
Priority: unspecified CC: agk, devurandom, heinzm, jbrassow, msnitzer, prajnoha, robbat2, zkabelac
Version: 2.02.171Flags: rule-engine: lvm-technical-solution?
rule-engine: lvm-test-coverage?
Target Milestone: RHEL 7   
Target Release: 2016-05   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.