The 4DOS command processor for MS-DOS

4dos, batch commands, grub 4 dos, dos 4, ms dos 4

unset-ting all but something

  Hiho!

 Wasn’t it a good idea to include a feature of "unset"ing all
environment variables *except* some crucial or specified — as
functionality of the snippet below, that does exactly that (can also be
made an alias)

      — Xenocryst

——- start-of-xunset.btm —–
iff "%1" eq "" .or. %@index[%1,?] ge 0 then
   echo Usage:%=%@name[%_batchname]  evar [ evar [ .. ] ]  %=|  *
excptvar [ excptvar [ .. ] ] %+ echo.
   echo %=tevar%=t%=t– environment variable to remove
   echo %=texcptvar%=t– environment to leave untouched %+ echo.
   echo %=tSecond variant removes all environment variables except
   echo %=tPATH COMSPEC and excptvar’s.
   quit 1
endiff
if "%1" ne "*" ( *unset/q %& %+ quit %_? )
*set | for i in (@con:) do ( %=
         set __n=0  %+  %=
         for j in (PATH COMSPEC %2&) do ( %=
            if "%@word["=",0,%i]" eq "%j" *set __n=%@inc[%__n] %=
         )  %+  %=
         if 0%__n==0  *unset/q %@word["=",0,%i] %=
      ) %+ *unset/q __n
——- end-of-xunset.btm —–

Sent via Deja.com http://www.deja.com/
Before you buy.

.
posted by admin in Uncategorized and have No Comments

Comments are closed.