-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMDLINE #51
Comments
From various emails regarding this issue: freecom sets the length byte of the command tail at PSP:80h to the "true" value of the commandline length. If the command line is 130 chars, this value will be 82h. However, since the PSP has a size of 256 only, just the first 127 bytes are copied to PSP:81h-ffh If a command line exceeds 126 bytes, the value at [PSP:80h] "should" be 0x7Fh ( and a 0x0D "should" be placed at [PSP:FFh] ) - that's at least what COMMAND.COM of Win95/98 does. The environment variable CMDLINE will then contain the full command line. It's documented in RBIL. see also in RBIL http://www.ctyme.com/intr/rb-4248.htm [PSP:80h] > 7Eh tells programs to get command line from environment variable CMDLINE In FreeCOM, MAX_EXTERNAL_COMMAND_SIZE is 125 (7Dh) because for normal command lines, psp_cmdlineLength is max that, followed by psp_cmdline with trailing \r AND \0 chars. Now when you have a LONG command line, two areas of the C code become relevant: shell/init.c is what received the command line when you start a new instance of FreeCOM,
The other part is that when you already have FreeCOM running
as well as shell/command.c,
This displays "Commandline longer than 125 characters." and leaves it up to the user to wonder whether that is a problem. Actually it cannot know which apps support long command lines, so thata probably is OK. Also note: CMDLINE is only used for com and exe, not for bat. Unfortunately, the above part is the ONLY place which uses MAX_EXTERNAL_COMMAND_SIZE, while the assert above hardcodes shell/cswapc.c contains this:
Because dosCMDTAIL is ((char far*)MK_FP(_psp, 0x80)) this would actually overflow the buffer by 1 byte Japheth's description implies that 127 has to be used as magic length, together with injecting an early \r into the PSP and not bothering to put an \0 after it. So proper code without long command line support was, only changing the SEE BELOW line:
But proper code for long command line support would make a case distinction for long versus short lines. Note that the assembly language parts of FreeCOM do not process long command lines at all, they simply assume that the C parts have already limited the PSP command line in a sensible way and do not care whether or not the environment contains any CMDLINE variable. This probably is OK. Best case for external programs utilizing CMDLINE:while parsing the command line is look at the length stored at PSP:80h. If it is less than 126, I use the data stored at PSP:81h up to the first 0Dh (Carriage Return) character. If the length is 126 or more, I look for the CMDLINE environment variable and use it (if it exists). If I can't find a CMDLINE environment variable, I go back and use what is stored at PSP:81h up to the first 0Dh character. I never actually use (or trust) the value stored at PSP:80h to provide the actual length, but simply use it as a flag to tell me whether or not I should bother looking for a CMDLINE environment variable. |
should now be fixed when exec'ing programs see ba97fbc |
as a unrelated note I need to reconfigure my editor, it is really messing up tabs/spaces |
I hit this in FreeDOS 1.3-rc4 when using
Note that More appropriate behaviour is seen with FreeCom 0.85a:
In this case the last |
see bug report (to be filled in later) - verify and correct if not that FreeCOM sets the PSP portion correctly for long command lines that pass the full command line in CMDLINE environment variable
The text was updated successfully, but these errors were encountered: