Welcome!

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

SignUp Now!

Directory stack empty when running TCEXIT?

Sep
45
1
I'm not sure when this behavior changed, or even if I've erroneously made some configuration change that caused it. So throwing this out there to see if anyone else sees the same thing.

I have TCEXIT.CMD script that saves some information for each open tab. I recently noticed (no idea when it started) that the directory stack wasn't being saved. After some debugging, it became clear that regardless of the state of the directory stack in a tab, when the TCEXIT is run the stack is empty. I confirmed this with a simple "echo %@dirstack[] >> C:\X\debug.txt" in my TCEXIT that clearly shows it's always returning 0.

I'm presently running 25.0.30. I've tried reverting to 25.0.25 (the oldest 25 version I have) and see the same behavior.
 
In my TCEXIT file, I save the most recent directory history using "dirhistory | tail /n 30 > c:\tcmd\ver25\dirhist.sav" so that I can restore it when I start up again. Why do you want to save the directory stack?
 
If I do a DIRS before TCEXIT, it shows the full stack. During TCEXIT, it outputs nothing. I'll assume it's something I screwed up in my config and look for it later.

I don't use directory history. I've been using Unix for 40 years and the shell's pushd/popd/dirs commands are second nature to me. I long ago wrote batch file thin wrappers around the TCC (and 4NT and 4OS2 before that) versions to give more Unix-like behavior (e.g. pushd with no args swaps the top two directories on the stack).
 
I had a bit of time to further investigate and have some further information.

If I close a tab via "EXIT", all is well - the directory stack is saved. However if I exit via the Home/Exit menu item (i.e. am closing Take Command), the directory stack is empty when running TCEXIT.

Is this WAD? I'm pretty sure this hasn't always been the behavior. I do realize the limited time to run TCEXIT, but I'm not doing anything time consuming, just dumping history & directory stack to a file.
 
This was changed in v25 -- the directory stack is stored in thread local storage for the main TCC thread. When you close TCC from another app (like TCMD) it gets the shutdown message and does the shutdown in a new thread, which has no directory stack.

I can move the directory stack back to global storage, though that will break a couple of other things. I'll have to think about how to work around it.
 
Thanks Rex.

While I'd appreciate the old behavior being restored, should it prove to be either a non-trivial performance hit or cause unwanted side-effects, don't sweat it. I've already implement a workaround by augmenting my existing pushd/popd/dirs scripts to always keep an up-to-date on-disk copy so I don't need to dump it in TCEXIT. That has the side benefit of having the list be up-to-date even if TCC is forcibly killed or if the box crashes. It does also have the downside of not reflecting any directory stack manipulation done outside of thise scripts (e.g. if I did a *popd for some reason), and possibly a trivial impact on pushd/popd speed, but those are minor considerations.

Given that it's taken this long for the change to be noticed, I can't imagine there are a lot of users relying on the old behavior. Though should the current behavior be retained, it should probably be documented somewhere.
 
Any update on this Rex? Is this still a change you're considering?

My workaround is functional, but not as convenient or as performant as the pre-v25 behavior.
 
Sweet. Thanks Rex. It seems to have been missed in the changelog, so I was unaware of the change in v26.
 

Similar threads

Back
Top