Re: command_line() bug in ex.exe 2.4

new topic     » goto parent     » topic index » view thread      » older message » newer message

Robert Craig wrote:

> Juergen Luethje wrote:
>> I ran the following small test program on Windows 98:
>> }}}
<eucode>
>> -- program 'cmd.ex'
>> constant CMD = command_line()
>> for i = 3 to length(CMD) do
>>    puts(1, "-" & CMD[i] & "-\n")
>> end for
>> if getc(0) then end if
>> </eucode>
{{{

>>
>> a) When calling it like this:
>>       exw.exe cmd.ex "c:\long dirname\"
>>    it displays, as I expected:
>>       -c:\long dirname\-
>>
>> b) But when calling it like this:
>>       ex.exe cmd.ex "c:\long dirname\"
>>    it displays:
>>       -c:\long dirname"-
>>
>>    It might look as if the backslash acts as an escape character here.
>>    But I think this isn't true, because in that case the first backslash
>>    should cause an error. Also, this should be consistent on all
>>    supported platforms IMHO.
>>    Calling
>>       ex.exe cmd.ex "c:\long dirname\\"
>>    displays
>>       -c:\long dirname\"-
>>
>>    In order to achieve the desired result, I have to omit the second
>>    double quote character:
>>       ex.exe cmd.ex "c:\long dirname\
>>    displays
>>       -c:\long dirname\-
>>
>>    Calling
>>       ex.exe cmd.ex "c:\long dirname\" "d:\long dirname\"
>>    displays
>>       -c:\long dirname" -
>>       -d:\long-
>>       -dirname"-
>
> The DOS command line is not handled the way you would like,
> but I don't have control over that. I just take the command line
> arguments as the system provides them to me. (Same on Linux
> and FreeBSD).
>
> For Windows, I get the command line as one long string,
> and I have to break it up into separate arguments, taking
> quotes into account. If there was something wrong,
> I might be able to correct it. But apparently you like the
> way exw does things.

Yes, exw.exe handles the command line in the way I (and probably most
other programmers) expect it. For the behaviour of ex.exe however, I
have no other word than 'strange'.

Who would expect that the command line
   ex.exe cmd.ex "c:\long dirname\" "d:\long dirname\"
would be split into (without the - characters)
   -c:\long dirname" -
   -d:\long-
   -dirname"-    ?

Who can tell me the rule for this, where is it documented?
When I want my Euphoria program to handle the command line correctly,
I need to know what command line options my program receives, don't I?

You write that ex.exe just takes the command line arguments as the
system provides them to it. AFAIK you use Watcom C for building ex.exe.
That means that "the system" for ex.exe consists at least of DOS and
Watcom C, right?

Let's see how DOS (DOS shell on Windows 98 here) itself handles command
line arguments:

---------------------------------------------------
@echo off
rem -- cmd.bat
rem -- display each command line argument in a line
:again
if %1!==! goto end
echo -%1-
shift
goto again
:end
---------------------------------------------------


Calling
   cmd.bat c:\long dirname\
displays:
   -c:\long-
   -dirname\-

Calling
   cmd.bat "c:\long dirname\"
displays:
   -"c:\long dirname\"-

Calling
   cmd.bat "c:\long dirname\" "d:\long dirname\"
displays
   -"c:\long dirname\"-
   -"d:\long dirname\"-

... as expected, and like exw.exe does it. (I don't care whether or not
both double quote characters that surround an argument are preserved.)


> I don't necessarily agree that Euphoria's
> command line arguments must be completely consistent
> across all platforms.

I would be helpful for developement of cross platform programs.

> The O/S and the command shell
> can process the command line before the program sees it.
> Even between DOS and Windows, I think there may be
> subtle differences beyond what you've observed.

Yes maybe. But despite all platform issues and beyond personal taste,
ex.exe's handling of the command line is obviously buggy, after the
information that I currently have probably caused by the Watcom C
compiler.

Regards,
   Juergen

-- 
A: Because it considerably reduces the readability of the text.
Q: Why?
A: Top posting.
Q: What is annoying in e-mail and news?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu