Bug 17612 - ability to parse argv[0]
ability to parse argv[0]
Product: Red Hat Linux
Classification: Retired
Component: popt (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Jeff Johnson
: FutureFeature
Depends On:
  Show dependency treegraph
Reported: 2000-09-18 13:06 EDT by Matt Domsch
Modified: 2008-05-01 11:37 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2000-10-09 13:38:41 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Matt Domsch 2000-09-18 13:06:09 EDT
popt cannot parse argv[0].  This is proper behavior if you're only using 
popt to parse command line arguments (even this is debateable, as one can 
have one binary application that is either hardlinked or simlinked to 
different names, and the application switches on argv[0] to act 
differently.  Think collage.), but if you want to use popt to parse 
configuration files, it would be good to be able to parse argv[0].
Comment 1 Jeff Johnson 2000-10-06 17:01:49 EDT
rpm uses popt to parse options, and does logic based on argv[0] tests. The 
"trick" is to
call poptGetContext with different values for the 1st and 4th args, and to make
use of nested "struct poptOption" tables using POPT_ARG_INCLUDE_TABLES to
eliminate redundancy.

Otherwise, I need an explicit example of what you are trying to do to even
an implementation. Feel free to reopen with a more explicit example ...
Comment 2 Matt Domsch 2000-10-09 10:56:04 EDT
MKJ wrote a nice program 'ttywatch'.  It uses popt to parse a configuration 
file (see below).  Essentially, each line is read in and placed in argv, and 
then parsed using popt.  As argv[0] can't be parsed, the first argument (--
name) actually has to be shifted by one, and a dummy value put in argv[0].
See MKJ for further details, and look at ttywatch in your CVS to see what he 

### A sample configuration follows:
# --name m1
# --name m2 --port /dev/ttyS1 --bps 9600
# --name m3 --port /dev/ttyS2 --bps 57600
### machine one (m1) is connected to ttyS0 and talks 115200 bps (default)
###   its log is kept in /var/log/ttywatch/m1
###   /dev/m1 is a link to /dev/ttyS0
### machine two (m2) is connected to ttyS1 and talks 9600 bps
###   its log is kept in /var/log/ttywatch/m2
### machine three (m3) is connected to ttyS2 and talks 57600 bps
###   its log is kept in /var/log/ttywatch/m3
--name ttyS0

Comment 3 Jeff Johnson 2000-10-09 13:38:38 EDT
Per MKJ, the functionality is apparently already in popt, but not documented. He
to send me a doco patch. Please reopen if on or the other of us Johnson's fails
to fix :-)

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