command.com: implement SET /E
For this to be implemented, cmd_set() has to be extended.
https://github.com/SvarDOS/edrdos/blob/d6a0051b10b2a12e7873d364e5be60bedefbc180/command/comint.c#L1592
Code has to be extended with a check for /E flag. There is a function that can be used, called f_check.
https://github.com/SvarDOS/edrdos/blob/d6a0051b10b2a12e7873d364e5be60bedefbc180/command/support.c#L1119
Output of the executable that shall be assigned to the environment variable must be redirected to a temporary file. The name of this file may be gathered by ms_x_unique which calls INT21,5a http://www.ctyme.com/intr/rb-3014.htm. After the executable ran with redirected STDOUT (and STDERR?) the first line of the temp file has to be read and stored into the env variable.
How to call the executable and do the redirection? The executable may also be a batch file, and we have make sure that this does not break command.com if called from within a batch file. There is already code for the CALL command, which supports redirection. Perhaps this could be reused. https://github.com/SvarDOS/edrdos/blob/d6a0051b10b2a12e7873d364e5be60bedefbc180/command/comint.c#L246
After the executable ran with redirected STDOUT (and STDERR?) the first line of the temp file has to be read and stored into the env variable.
FreeCOM actually writes a redirection using the > operator into a temporary buffer. So it definitely only redirects stdout.
Actually the redirection is not performed when calling cmd_call(). Redirection is done by parse() which gets called up in the call stack before cmd_set(). So if I call cmd_call( "PROGRAM > test.txt" ) from within cmd_set() it has no effect. It is also that parse() does not do redirection if a redirection is already in place. This may be the case if SET /E... is called from within a redirected batch file.
So my current plan is to setup the redirection directly within cmd_set (and not issuing via redirection operatr >), specifically for capturing the data for the environment variable. But first I have to investigate what effect this has on error handling. For example, if SET /E ABC=TEST.BAT is invoked, and TEST.BAT is terminated via CTRL+C, COMMAND.COM performes a longjmp to a handler routine out of cmd_set. Then the code to revert the redirection would not be executed. Have to think a bit more about it...