View Issue Details

IDProjectCategoryView StatusLast Update
0024674FPCRTLpublic2014-03-04 16:19
ReporterAntonAssigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformAllOSOS Version
Product Version2.6.3Product Build 
Target Version3.0.0Fixed in Version2.6.4 
Summary0024674: Getoptionvalue returns next option if no value is provided
DescriptionWhen using command line parameters with optional value, if no value is given then next option is returned instead of a empty string.

IMHO the problem is that there is no check on the first character in getoptionvalue (custapp.pp)

Steps To Reproduceexample
progname -c test -d -p
getoptionvalue('c') gives 'test'
getoptionvalue('d') gives '-p'
getoptionvalue('p') gives ''

Additional Information330 else
      begin // short options have form '-o value'
      If (I<ParamCount) then
        Result:=Params[I+1]; <-- check first character = '-'
      end;
335 end;
TagsNo tags attached.
Fixed in Revision26853
FPCOldBugId
FPCTarget
Attached Files

Activities

Jonas Maebe

2013-06-27 11:33

manager   ~0068587

Normally, you as a programmer determine which options are followed by a value and which are not, and you should only call getoptionvalue for options that take a value. Unless it is stated that option values cannot start with '-', the behaviour looks correct to me.

Anton

2013-06-27 18:20

reporter   ~0068609

So there are 2 options

1 the description is wrong --> The function returns the specified value, or the empty string if none was specified.

2 there should be some checking done to options for the "optionchar"


Description:

GetOptionValue returns the value of an option. Values are specified in the usual GNU option format, either of

--longopt=Value

or

-c Value

is supported.

The function returns the specified value, or the empty string if none was specified.

Depending on the value of the CaseSensitiveOptions property, the search is performed case sensitive or case insensitive.

Options are identified as command-line parameters which start with OptionChar (by default the dash ('-') character).

Jonas Maebe

2013-06-27 18:48

manager   ~0068610

Then it indeed seems like a bug in tcustomapplication

Michael Van Canneyt

2014-01-24 16:14

administrator   ~0072640

Fixed, thanks for reporting this.

Jonas Maebe

2014-03-04 16:17

manager   ~0073419

Merged in spite of 2.8.0 target version

Issue History

Date Modified Username Field Change
2013-06-27 11:22 Anton New Issue
2013-06-27 11:33 Jonas Maebe Note Added: 0068587
2013-06-27 11:33 Jonas Maebe Assigned To => Jonas Maebe
2013-06-27 11:33 Jonas Maebe Status new => feedback
2013-06-27 18:20 Anton Note Added: 0068609
2013-06-27 18:20 Anton Status feedback => assigned
2013-06-27 18:48 Jonas Maebe Note Added: 0068610
2013-06-27 18:48 Jonas Maebe Assigned To Jonas Maebe => Michael Van Canneyt
2014-01-24 16:14 Michael Van Canneyt Fixed in Revision => 26577
2014-01-24 16:14 Michael Van Canneyt Note Added: 0072640
2014-01-24 16:14 Michael Van Canneyt Status assigned => resolved
2014-01-24 16:14 Michael Van Canneyt Fixed in Version => 2.7.1
2014-01-24 16:14 Michael Van Canneyt Resolution open => fixed
2014-01-24 16:14 Michael Van Canneyt Target Version => 2.8.0
2014-03-04 16:17 Jonas Maebe Fixed in Revision 26577 => 24674
2014-03-04 16:17 Jonas Maebe Note Added: 0073419
2014-03-04 16:17 Jonas Maebe Fixed in Version 2.7.1 => 2.6.4
2014-03-04 16:19 Jonas Maebe Fixed in Revision 24674 => 26853