Welcome!

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

SignUp Now!

Request Re Aliases CD_LEAVE and CD_ENTER

Jun
552
4
It would be helpful if the aliases CD_LEAVE and CD_ENTER would be executed only when there is an actual directory change. Right now, I'm getting things like this (with my debugging output):

Alias CD_LEAVE
%1=C:\Users\Jay\Dropbox
%2=C:\Users\Jay\Dropbox
Alias CD_ENTER
oldcwd=C:\Users\Jay\Dropbox
newcwd=C:\Users\Jay\Dropbox

As you can see, the directory was not actually changing.

I also just observed that performing "bat:vedit.btm" to launch my text editor via a script causes an invocation of the two aliases without any change of directory.

TCC(27.01.23): C:\tcmd\ver27>bat:vedit
Alias CD_LEAVE
%1=C:\tcmd\ver27
%2=C:\tcmd\ver27
Alias CD_ENTER
oldcwd=C:\tcmd\ver27
newcwd=C:\tcmd\ver27

TCC(27.01.23): C:\tcmd\ver27>

I want to use these aliases to run a batch file (autoex.btm, if present) when I first change to a new directory. It typically displays a file listing or some other information of use to a project that would be carried out in that directory (e.g., defining some special aliases or launching a program). So I really don't want those aliases running all the time when no change is actually taking place. They should run only when the CD or CDD command is run (or the automatic equivalents, e.g., the command c:\temp\).

In the past, I have done this with a very complex prompt variable that includes a lot of %@exec[] calls. That all worked fine in version 25. The new aliases could make things much easier if they worked better.

In addition, there is something about that complex prompt defintion that causes version 27 to crash very frequently. I very quickly had to stop using it and went back to version 25. It appears from my testing today that the problem arises from that prompt code.
 
Jay, did you try pointing CD_ENTER at a BTM file? When I do that, crazy things happen! ... so crazy that I can't figure out steps to demonstrate what happens.
 
CD_ENTER and CD_LEAVE are executed when a directory change is done in TCC; they do not verify that you're not trying to change to the existing directory. They are NOT tied only to CD & CDD; there are a lot of other actions that can trigger a directory change.

I am unlikely to change this as it would be a breaking change for users who are relying on the existing behavior. For what you're trying to do, it would be easier for you to create a CD & CDD alias.

Regarding your prompt - the only thing that has changed in the prompt code since v25 is the new $ metacharacter. If you can reproduce the error, please post your PROMPT string.
 

Similar threads

Back
Top