changing the master environment, shells

changing the master environment, shells

Post by Harry Pull » Wed, 10 Jul 1991 21:00:34

> >> OK, how do I access (and modify) strings in the MASTER environment...

> >The only way that I know of makes use of the monderful `feature' of MS-DOS:
> >the ability to do anything at all to the machine.  Chain through the
> >malloc arena headers until you find the PSP of your parent.  This has a
> >pointer to the environment. Modify it at will, and there you are.

> >Beware, too, that this probably won't work under Novell -- the ANET
> >shell modifies the original DOS PSP to point to a different environment,
> >which is also linked to the ANET shell.  

> is not all that might be wished for.  As K. Khan says, there are programs
> with which this technique will fail.  He mentions Novell.  Two others are
> the MKS shell and 4DOS.  The MKS shell stores its environment differently,
> as it must, in order to implement all of the features of the Korn Shell.
> 4DOS has the ability to swap it's environment to secondary storage as part
> of it's memory conservation features and, thus, you may or may not be
> able to locate the master environment.
> Modifying any environment other than the current one is an elusive
> and unreliable goal.

While we are on the topic of replacement shells and environments, I will mention
that I too have written a replacement for COMMAND.COM.  Unlike 4DOS, it is not
compatible with the MS-DOS shell, at the command line or in the batch files.  It
offers many features of the UN*X C-shell (aliasing, history, filename completion
etc...) and a new batch file language - a block-structured one (while, for
switch, etc...).

To get back on the topic of accessing the master environment, my shell has a
feature which makes this very easy: when a child program terminates, the shell
searches the primary swap device for a file called ENVRNMNT.SYS (if the file is
not found in the primary swap device, then all other devices are searched except
for the floppy drives).  It reads this file and uses each line as if you had
typed 'set LINE'.  This effectively updates the master environment.  All you
must do is write a file of the form:


(... you get the picture)
and call it ENVRNMNT.SYS in the root directory of the swap device.

The shell is a beta stage.  I use Ralf Brown's code (SPAWNO) to swap to XMS, EMS
and disk.  I like it much better than COMMAND.COM, 4DOS or any other shell
(I wonder why ;-).  If you want a beta copy, let me know.  

I must warn, however, that my time is limited, so I will not send out alot of
copies if I get too many requests.  This is why I only posted it to
alt.msdos.programmer :->.  I hope to have a gamma version complete *very* soon
(a couple of weeks %-) and then I will post it or submit it somewhere.  It will
be PD, make donations if you want: no registration, no guaranteed support.

~ Harry C. Pulley, IV %(:-{Q} ~