From: David A. <w.d...@gm...> - 2013-06-05 15:08:30
|
On Wed, 2013-06-05 at 10:50 -0400, Gil Barmwater wrote: > David Ashley wrote: > > On Wed, 2013-06-05 at 09:44 -0400, Gil Barmwater wrote: > > > > Just so everyone understands the base issue here I will state it. In > > windows, the Rexx BIF arg(1) returns an exact duplicate of the command > > line arguments. In a *nix environment you may or may not get get an > > exact copy of the original command line and for certain you will NOT get > > an exact copy if any of the space delimited arguments contain embedded > > spaces surrounded by double quotes. This is because Rexx can obtain a > > copy of the windows command line from an OS API. In a *nix environment > > Rexx has to reconstruct the command line from the passed arguments and > > unfortunately it does a really poor job of it. The really unfortunate > > thing is that it is much too late to change that implementation as that > > would have a terrible impact on existing programs. So we really need a > > new and correct implementation to obtain the C args/command line > > arguments on *nix platforms. > > > > Wow! I had no idea *nix platforms had such a problem. Has anything > changed in that world to make it "easier" to get the command line from > the OS? Or is the way it is "reconstructed" just not optimal? > > Just one other thought on a possible implementation. Since C uses > 0-based arrays and Rexx uses 1-based arrays, I suggest that the method > added to .environment NOT be an array (like .argv[]). This would be > confusing, prone to errors and difficult to explain. Instead, I would > propose just providing a string of the command line (e.g. .commandline) > that the user can then examine or parse as needed. > There is a Windows API which will hand you a copy of the command line from the starting process. Rexx uses this to make a copy that is returned via the arg(1) BIF. *nix has no such API. You have to reconstruct the command line from the arg array. And if an argument was surrounded by double quotes then those quotes are stripped off before Rexx sees the arguments. During the reconstruction of the command line by Rexx it makes no attempt to examine the C arg for embedded spaces. Thus a command line that looks like this this is "the thing" will become this is the thing when you use arg(1) to examine it. As you can see it now becomes impossible to determine what the original command line actually was and to make any kind of guess as to what words should be grouped logically together. This "bug" is the greatest weakness for ooRexx in a *nix environment. Programmers in that environment have an expectation of obtaining the command line arguments as they really were supplied to the program. And not some hacked together version of those arguments. The real problem here is that it is much too late to change any of this. The impact on existing programs would be too great. So we need a new mechanism to obtain the real C arguments that will not impact existing programs. Adding some new methods to the .environment class is as good a way as any to provide the functionality needed to implement access to the real C args. David Ashley |