koreth%panarthea.ebay@sun.com (Steven Grimm) (07/24/89)
Submitted-by: Thomas_E_Zerucha@cup.portal.com (Thomas E. Zerucha) Posting-number: Volume 2, Issue 64 Archive-name: environ Environ.prg is a program to set the desktop's environment from the auto folder using a text file (environ.dat) in the root directory of your boot disk. This way you can have your environment set for your shell without long profiles or logins, and can put .rsc files where they can always be found (on another drive). #!/bin/sh # shar: Shell Archiver (v1.22) # # Run the following text with /bin/sh to create: # ENVIRON.DAT # ENVIRON.DOC # ENVIRON.S # sed 's/^X//' << 'SHAR_EOF' > ENVIRON.DAT && XPATH=;d:\gemprogs;d:;d:\bin;d:\lang;d:\scripts;d:\usrbin;. XTEMP=c:\tmp\ XINCLUDE=d:\include\ XSYMB=d:\lang\ XLIB=d:\lib\ XSTARTUP=d:\lib\gemstart XRUNTIME=d:\lib\gemlib XSUFF=,.prg,.ttp,.tos XLIBPATH=d:\mwlib,d:\lang,. XINCDIR=d:\mwinc\ XTMPDIR=c:\tmp\ XTIMEZONE=EST:0:EDT XEDITOR=sedt.ttp XSEDT=d:\include\ XSHELL=csh.tos XHOME=d:\ SHAR_EOF chmod 0644 ENVIRON.DAT || echo "restore of ENVIRON.DAT fails" sed 's/^X//' << 'SHAR_EOF' > ENVIRON.DOC && XENVIRON.PRG X - set desktop environment (like PATH, HOME, and other things for shells) X from \AUTO folder. X X Place ENVIRON.PRG in the \AUTO folder. X X Uses ENVIRON.DAT as a standard ASCII text file containing the X environment (e.g try "printenv >c:\environ.dat" and use that X after fixing the PATH= as shown below). X X Note that GEM can find .RSC files on the first entry in the path, X but ignores the first character, e.g. the following works: X XNote | the extra semicolon, and that you need semicolons and not commas X | for the PATH to work for the desktop and .rsc files. X v XPATH=;d:\gemprogs;d:;d:\bin;d:\lang;d:\scripts;d:\usrbin;. XTEMP=c:\tmp\ XINCLUDE=d:\include\ X X All my .rsc files (and some configs and such) are in my d:\gemprogs, X so I can double click a document (installed as per the desktop X dialog, e.g. .DOC=1stword) anywhere on any disk and the program X will come up properly, and I can go "gem program doc" from any X folder under a shell and everything will work. X X (Tech note: It is documented somewhere that the way GEM searches X for the .RSC files (and there is a call that looks for files X in the same way for setups, etc.) is to first search the current X directory, then the root directory on the disk, then the PATH= X value, which defaults to A:, which is why it spins your floppy X before it says it can't find the resource. What my program does X is to read in environ.dat (must be in root), change linefeeds X to nulls and delete the carriage returns and put nulls at the X end, then point the desktop environment to that buffer.) X X What is also useful is that most shells will take these values X so you don't have to have a big profile.sh or login.sh files X just to set the environment. X X Make sure all lines are of the form SYM=value, and don't put X any blank lines or spaces unless needed (see your shell docs). X X Source is included for the curious. SHAR_EOF chmod 0644 ENVIRON.DOC || echo "restore of ENVIRON.DOC fails" sed 's/^X//' << 'SHAR_EOF' > ENVIRON.S && X .text X*housekeeping X move.l a7,a5 X move.l 4(a5),a5 ;compute size for TSR call X move.l $c(a5),d6 ;text X add.l $14(a5),d6 ;data X* add.l $1c(a5),d6 ;bss X add.l #$100,d6 ;basepage X add.l #$40,d6 ;saftey X*open X move.w #0,-(sp) X pea envfstr X move.w #$3d,-(sp) X trap #1 X addq.l #8,sp X move.w d0,handl X blt bexit X*read X pea workar X move.l #8192,-(sp) X move.w handl,-(sp) X move.w #$3f,-(sp) X trap #1 X add.l #12,sp X add.w d0,d6 ;length of used BSS = length of file X move.l #workar,a0 X add.w d0,a0 ;point to end of environment X move.b #0,(a0) ;put nulls afterword X move.b #0,1(a0) ;put nulls afterword X X;change linefeeds to nulls X move.l #workar,a0 X move.w d0,d1 Xzaplflp: X cmp.b #10,(a0) X bne.s notlf X move.b #0,(a0) Xnotlf: X addq.l #1,a0 X dbf d0,zaplflp X;remove returns X move.l #workar,a0 X move.l a0,a1 Xzapcrs: X cmp.b #13,(a0) X bne.s notcr X addq.l #1,a0 X bra.s zapcrs Xnotcr: X move.b (a0)+,(a1)+ X cmp.b #0,(a0) X dbeq d1,zapcrs X move.b #0,(a1) X X add.w #$40,d6 ;safety X*close X move.w handl,-(sp) X move.w #$3d,-(sp) X trap #1 X addq.l #4,sp X X* alter vector X move.l #doit,-(sp) ;point to the vector changer code X move.w #38,-(sp) ;we want to do it in supervisor mode! X trap #14 ;execute it! X addq.l #6,sp X* tell everyone we are here X pea msg1 X move.w #9,-(sp) X trap #1 X addq.l #6,sp X* TSR X clr -(sp) ;exit but stay X move.l d6,-(sp) X move #$31,-(sp) X trap #1 X Xbexit: move #0,-(sp) X trap #1 X* set env upon startup Xmovenv: X move.l a7,a5 X move.l 4(a5),a5 X move.l a5,a4 Xlinkup: X move.l $24(a4),a4 X movea.l $2c(a4),a3 X cmp.w #0,(a3) X beq.s setwork X move.l a4,a5 X bra.s linkup Xsetwork: X X move.l #workar,$2c(a5) X move.l shlsav,a5 X jmp (a5) X*** X* install (in super) vector Xdoit: move.l $4fe,shlsav ;move X move.l #movenv,$4fe ;move X rts ;and return X*** X************************* X .data Xmsg1: dc.b 'Environment Set\r\n',0 Xenvfstr: dc.b 'ENVIRON.DAT',0 Xhandl: dc.w 0 Xshlsav: dc.l 0 X .bss Xworkar: ds.b 8192 X .end SHAR_EOF chmod 0644 ENVIRON.S || echo "restore of ENVIRON.S fails" exit 0