lotto@talcott.UUCP (Jerry Lotto) (11/23/85)
We are doomed to repeat this over and over as more people find out how useful environments can be. I hope to add something new to the conversation as well. In MS-DOS 3.1, COMMAND.COM can be invoked with command line arguments by using the SHELL feature in CONFIG.SYS. As most people know already, the syntax is SHELL=d:\path\COMMAND.COM /P d:\path /otherswitches. The /P switch tells COMMAND that this is a "P"ermanent copy and is the inverse of the "C"ommand switch which tells it to execute a command (also on the line) and then exit. The installation code for COMMAND (starting at CB0 under debug) reveals some interesting features. After arranging a few interrupt vectors and determining the location to load things, COMMAND quickly determines what size the environment is to be. Around D04 to D16, it figures out the amount of available memory, the maximum size of the environment 3E (62) paragraphs, and the default size 0A (10) paragraphs. Changing this 0A will result in a larger default, up to the 3E limit. If COMMAND has not inherited an environment from somewhere else, (determined from the segment style address at offset 2C in the PSP), it points to an internal copy at C10. The string PATH=, nul, COMSPEC=/COMMAND.COM is already in place. The / is NOT a typo, this IS what is there. Then, COMMAND gets the switch character by well known means (reserved function 37) and sees if it is a /. If so, the environment pathchar is changed at a hard coded offset of 0E from the start. Sound like anticipation of being called from Xenix? After figuring out what drive all this is coming from and doing the appropriate bookeeping, COMMAND then finishes reading off the command line. Possible switches are: F - looks like "forever". All I can figure out is that it causes DOS to ask Abort, Retry, Ignore. Without this switch, DOS does a function 51 (you guessed it, reserved) and then an IRET. Maybe DOS execs a copy of COMMAND as an error handler for some situations. D - Appears similar to C but saves less information about the current process. E - must be followed by a : and a decimal number not exceeding the limit set around D04. All COMMAND does is replace the memory location to which the 0A was moved with your number. Supported or not, it is a much cleaner method of expansion (up to 1K) than a direct patch. Further arguments are treated as various device/file names and COMMAND attempts to create handles to them. The teaberry shuffle with the switchar is interesting to say the least, and without taking to much more of your time, let me say that further inspection reveals similar doings again and again. I doubt that the F and D switches will end up being as useful as E, but if anyone takes the time to investigate further, I am always interested in the results. -- Gerald Lotto - Harvard Chemistry Dept. UUCP: {seismo,harpo,ihnp4,linus,allegra,ut-sally}!harvard!lhasa!lotto ARPA: lotto@harvard.EDU CSNET: lotto%harvard@csnet-relay