Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Wildcard Display of Alias Definitions

Jun
762
16
I have encountered problems when trying to display all matching alias definitions using '' when one of the aliases has '' in its name. For example, consider the following aliases

zz=zza
zz*a=echo this is alias zza
zz*b=echo this is alias zzb

Notice that the following displays only the first alias that literally matches "zz*".

Code:
TCC(34.00.12): C:\temp>alias zz*
echo this is alias zza

Inserting a '?' character solves the problem.

Code:
TCC(34.00.12): C:\temp>alias zz?*
zz=zza
zz*a=echo this is alias zza
zz*b=echo this is alias zzb

The '?' character (which in TCC can be zero characters) breaks the exact match to the start of "zz*a".
 
Based on the above observation, I just wrote a batch script replacement for ALIAS that automatically changes asterisks to '?*'. That has always been what I really wanted. The script is very simple:

Code:
iff %# EQ 0 then
  *alias %$
elseiff %@regex["[*]",%$] EQ 1 then
  *alias %@replace[*,?*,%$]
else
  *alias %$
endiff

I noticed that this fails with a command tail of "/=". The equal sign is swallowed, and the command tail is just the slash character. Maybe I should know why that is, but I can't remember. I can fix that by adding an extra test.

Code:
elseiff "%1" EQ "/" then
  *alias /=
 
Well, I wrote too fast about that script. It has some serious problems because of the interpretation of the command line before the script is called. When I tried running alias zz=echo Tail = %$, it locked up. For one thing, the back-quotes get stripped, which means that the rest of the command line is not protected. And the equal sign also disappears.

Back to the drawing board...
 
Back
Top