Bug fix: SessionManager>>cmdLineFlags doesn't accept empty arguments

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Bug fix: SessionManager>>cmdLineFlags doesn't accept empty arguments

Carsten Haerle
When you start an application with an empty arguments (by specifiying an
empty string with "" on the command line), the session manager method
crashes. Below is the fix.

!SessionManager methodsFor!

cmdLineFlags
 "Private - Answer the Set of flags specified on the command line.
 Currently this is rather simplistic, since it doesn't handle parameters
 with an argument, if the argument is separated from the parameter name
 by whitespace. The VM can't handle these anyway, as it knows nothing about
 the potential parameters, and so treats the first argument which does not
 beging with $/ or $- as the name of the image file. So, currently,
parameters
 with arguments must be specified without any whitespace between the
parameter
 name and the parameter value."

 cmdLineFlags isNil
  ifTrue:
   [cmdLineFlags := Set new.
   self argv
    do: [:a | (a notEmpty and: ['/-' includes: a first]) ifTrue:
[cmdLineFlags add: (a copyFrom: 2)]]].
 ^cmdLineFlags! !
!SessionManager categoriesFor: #cmdLineFlags!accessing!private! !