Block external aliases, functions, etc in BTM scripts

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
As I want to block external aliases, etc to interfere with my scripts, I add these lines to these scripts:
Code:
unalias *
unfunction *
option //FuzzyCD=0
But here comes the problem: If I don't forget ....

So I came up with this:
Code:
alias SETLOCAL=`*setlocal %$ & IFF .%_batchname. ne .. THEN (option //FuzzyCD=0 & unfunction * & unalias *)`
Because SETLOCAL is de facto one of the first two lines of your script, it will block those things automatic.
The even better thing is: When the next SETLOCAL in your script comes along, the SETLOCAL alias has already unaliased itself and a normal SETLOCAL is executed :-)
After your script has ended (=ENDLOCAL), the SETLOCAL alias is available again.

If SETLOCAL is used on the command-line, the blocking part will be ignored.

EDIT: Forgot to mention that a SETLOCAL in your TCSTART.btm can remove your aliases.
Just a FYI, because why would you have a SETLOCAL in TCSTART?
 
Last edited: