WAD Failure of Alias Command with /Z Option

Jun 2, 2008
388
2
Newton, MA
I have always used an alias with "unalias * & alias /r alias.cfg diralias.cfg" to clear and reload my definitions of regular and directory aliases. Today I noticed the /Z option and tried using "alias /r /z alias.cfg diralias.cfg" instead. I end up with no regular aliases defined! The command apparently does not work with multiple files. When I run "alias /r /z alias.cfg & alias /r diralias.cfg", the aliases get loaded correctly. It seems that the /Z option is applied (erroneously) to each file in the list. It should be applied only once before any files are loaded.

I have tried this in versions 25 and 27.
 

rconn

Administrator
Staff member
May 14, 2008
12,421
152
WAD - /Z clears the entire alias list before the /R reads a file. (The help file implies this but doesn't make it as explicitly clear as might be desired.)

If /Z worked with multiple files, it would be worse than useless (and slower than a simple /R) - it would have to read both the entire existing alias list and the entire /R file to determine which entries to delete/replace with new entries. /Z is faster because it wipes the list and /R doesn't have to scan it for every entry.
 
Jun 2, 2008
388
2
Newton, MA
OK. I see your point. I know that the two files contain completely different types of aliases, but the command doesn't know that.

Does using the /Z option have any advantage over first deleting all aliases with "unalias *"? Of course, the time in my case is completely negligible in any case.

P. S. Why are all the editing options/icons (bold, italic, etc.) grayed out for me?
 

rconn

Administrator
Staff member
May 14, 2008
12,421
152
"alias /R /Z" is somewhat faster (because the /R doesn't have to check for an existing name) & easier to write than "unalias * & alias /R", but there's no functional difference. Unless you have a few thousand aliases you probably won't notice the time.

I don't know what editing options you're referring to.
 
  • Like
Reactions: Joe Caverly
Jun 2, 2008
388
2
Newton, MA
What happens if the file with alias definitions has multiple definitions for the same alias? Does "alias /r" check with each definition for a prior definition? Another way to put that: suppose I ran "copy alias.cfg+diralias.cfg al.cfg" to combine all my definitions into one file and then ran "alias /r /z al.cfg" to load them? If that would work, then why can't the /Z option be used with a list of files, all of which are simply read in without checking?

By editing options, I'm talking about the screen in this forum for composing messages (like this one). I cannot make text bold, for example, because the "B" icon above, along with all the others except for the three-dots ones, is greyed out. I seem to be in plian-text-only mode.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,518
96
Albuquerque, NM
prospero.unm.edu
By editing options, I'm talking about the screen in this forum for composing messages (like this one). I cannot make text bold, for example, because the "B" icon above, along with all the others except for the three-dots ones, is greyed out. I seem to be in plian-text-only mode.

How about the icon that looks like two brackets [ ] ? Does that one work?
 
Jun 2, 2008
388
2
Newton, MA
There was no such icon. However, I tried all three triple-dot icons for more options, and the one at the far right had it. When I clicked it, the other options became active. I can now make bold text. Thank you!!!
 
May 20, 2008
11,629
110
Syracuse, NY, USA
How about the icon that looks like two brackets [ ] ? Does that one work?
Good one Charles! That toggles all the icons to/from greyed out. The [ ] icon is on the far right, near "Preview".

1622601741610.png


Yes/no?
 
May 20, 2008
11,629
110
Syracuse, NY, USA
Aha! Jay must be using the "Flare (Child)" style which has a different editing toolbar. Jay, if you haven't tried it, try the "Default" style. The style picker is way at the bottom of the page.
 
Jun 2, 2008
361
4
I believe I have the Default style set and a zoom level of 150% in my browser pushes the Toggle BB code button into the More options menu.

Edit: Actually, I should say it gets pushed into a 3rd More options menu that gets created on the right, next to the Preview button (and the text for the Preview button is eliminated).
 
Jun 2, 2008
388
2
Newton, MA
Thank you to all of you. I'm now in the standard style, and everything looks much better!
 
Jun 2, 2008
388
2
Newton, MA
Returning to the original topic of the /Z option for alias...

I did some experiments with reading aliases from files. With just the /R option, the command reads in the lines. If an alias has already been defined, it is overwritten, so one does not end up with multiple definitions.

With the /Z option added, all existing definitions are removed, and the definitions in the file are added, even if there are multiple definitions for the same alias. When there are multiple definitions, the first definition in the file is the one that is run. Since the /R option adds the new definitions to the end of the list, it is critical to search for -- and remove -- any previous definition.

I've now gone back and done some further experiments after using /R /Z to get two definitions for the same alias.

Code:
TCC(27.01.23): C:\tcmd\ver27>alias /r /z diralias.cfg

TCC(27.01.23): C:\tcmd\ver27>alias | tail /n 3
lap_nergc:=lap_docs:genealogy\conferences\NERGC2011\
zzz=echo Def 1
zzz=echo Def 2

If I now define zzz again, only the first one is replaced. This makes sense, since that's the one that TCC will use, so why waste time looking for more.

Code:
TCC(27.01.23): C:\tcmd\ver27>alias zzz=echo Def 3

TCC(27.01.23): C:\tcmd\ver27>alias | tail /n 3
lap_nergc:=lap_docs:genealogy\conferences\NERGC2011\
zzz=echo Def 3
zzz=echo Def 2

To see how much time it takes to load all of my aliases from the pair of files including all the overhead of duplicate checking, I ran the following a few times.

Code:
TCC(27.01.23): C:\Users\Jay\Dropbox>timer alias /r %tcmddir\alias.cfg %tcmddir\diralias.cfg
Timer 1 on:  0:03:29
Timer 1 off:  0:03:29  Elapsed: 0:00:00.110

TCC(27.01.23): C:\Users\Jay\Dropbox>timer alias /r %tcmddir\alias.cfg %tcmddir\diralias.cfg
Timer 1 on:  0:03:39
Timer 1 off:  0:03:39  Elapsed: 0:00:00.109

TCC(27.01.23): C:\Users\Jay\Dropbox>timer alias /r %tcmddir\alias.cfg %tcmddir\diralias.cfg
Timer 1 on:  0:05:06
Timer 1 off:  0:05:06  Elapsed: 0:00:00.110

The files each have about 1000 lines, a few of which are comments. One would have to have a lot of aliases for this to be an issue.
 

Similar threads