1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Block external aliases, functions, etc in BTM scripts

Discussion in 'T&T - Aliases' started by MaartenG, Mar 23, 2017.

  1. MaartenG

    Aug 3, 2016
    Likes Received:
    As I want to block external aliases, etc to interfere with my scripts, I add these lines to these scripts:
    unalias *
    unfunction *
    option //FuzzyCD=0
    But here comes the problem: If I don't forget ....

    So I came up with this:
    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?
    #1 MaartenG, Mar 23, 2017
    Last edited: Mar 23, 2017

Share This Page