WAD Setlocal issue

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Jul 6, 2008
241
3
#1
Setlocal is removing aliases when used in V21.00.28
This is only when using setlocal/endlocal in an alias. Batch files aren't affected.
Code:
v21.00.28
C:\JPSoft>alias test=`setlocal & ech This is a test alias to determine what aliases are active after issuing a setlocal command
& endlocal`

v21.00.28
C:\JPSoft>test
TCC: Unknown command "ech"

v21.00.28
C:\JPSoft>alias ech
if .%1 eq . (ah ech) else (echo. & echo %$ & echo.)
Hopefully this was behavior unintentional. If so, the documentation needs clarification.
V17, V19, & V20 acts as expected. No V18 to test. V20 example:
Code:
v20.11.46
C:\JPSoft\tcmd20x64>alias test
setlocal & ech This is a test alias to determine what aliases are active after issuing a setlocal command & endlocal

v20.11.46
C:\JPSoft\tcmd20x64>test

This is a test alias to determine what aliases are active after issuing a setlocal command
 
Jul 6, 2008
241
3
#3
Thanks for the WAD clarification.

I did read the "What's New", as well as other documentation such as Setlocal and Endlocal...

For me, this "copying global aliases to a local list" didn't equate to aliases literally not working within a Setlocal/Endlocal pair used in an alias definition and aliases working when used in a batch file.

If I change to local aliases within an alias before using a Setlocal/Endlocal pair will the specific alias have access to these local aliases without redefining them inside the Setlocal/Endlocal pair?

So does this mean in order to use the copied "local list" I have to reload aliases within the actual alias?

A better question is; how do I use this local alias list within an alias that uses a Setlocal/Endlocal pair?

Is this new behavior something that could be an option to turn on/off? If so, I will add it to the suggestion Forum.

I recommend an explicit clarification be added to the help files. "Aliases do not work with a Setlocal/Endlocal pair within alias definitions. Batch file behavior is not affected."
 
Jul 6, 2008
241
3
#5
SETLOCAL in v21 was changed to preserve global aliases (by request from a number of users). If you use local aliases, you can add/modify/delete them inside the SETLOCAL and the change will be preserved after the ENDLOCAL.
So I tried using local aliases with an alias using a set/endlocal pair.

I don't see that the newly defined alias NEW1 is preserved after the ENDLOCAL as I understand your quoted response above. Clearly I don't understand how this is supposed to work. :banghead:
Code:
v21.00.28
C:\JPSoft>ver

TCC  21.00.28 x64   Windows 10 [Version 10.0.14393]
v21.00.28
C:\JPSoft>alias test5=`alias /L & a New1 & echo. & setlocal & ech Testing.... & alias New1= `echo this is a test of adding alias New1`  &  New1 & endlocal & ech After the endlocal & a New1`
v21.00.28
C:\JPSoft>alias /l
v21.00.28
C:\JPSoft>test5
          Aliases Beginning with New1*
TCC: Not an alias "New1*"

Testing....

this is a test of adding alias New1

After the endlocal

          Aliases Beginning with New1*

TCC: Not an alias "New1*"
Just to be clear, here are the aliases used in the above TEST5 alias.
ECH & A both work inside TEST5 once I set LOCAL aliases. They both fail, inside TEST5 without the "alias /L", as I now understand the document.
Code:
v21.00.28
C:\JPSoft>alias ech
if .%1 eq . (ah ech) else (echo. & echo %$ & echo.)
v21.00.28
C:\JPSoft>alias a
 iff .%1 == . then & (ah a) & elseiff isalias %1 then & (fa %1 & echo. & *alias %1) & else & (echo. & Scrput -1 10 Bri Red on W
hi Aliases Beginning with %1* & echo. & *alias %1* & echo.) & endiff