PRE_EXEC?

May 20, 2008
9,195
60
Syracuse, NY, USA
Can the special PRE_EXEC alias prevent the execution of the current command (conditionally, of course)?

Again I was thinking of Steve's wanting to handle the loss of the current directory gracefully. This alias does it, but uses a plugin.
Code:
v:\> alias pre_exec
if not isdir %_cwd ( cdd v:\ & genbreak )
With that, if the network was disconnected and the current directory invalid, I see for example
Code:
\\lucky\v$> dir
TCC: (Sys) The specified network name is no longer available.
^C
v:\>
The error message is nice; the "^C" not so nice. I was wondering if it could be done with only built-in tools.
 
May 20, 2008
3,520
3
Elkridge, MD, USA
PRE_EXEC is not executed until the next command is entered; PRE_INPUT is.
But what about the case the TCC instance is not in active use (may even be minimized or not the current TCMD tab)when the CWD becomes inaccessible?
 
May 20, 2008
9,195
60
Syracuse, NY, USA
PRE_EXEC is not executed until the next command is entered; PRE_INPUT is.
But what about the case the TCC instance is not in active use (may even be minimized or not the current TCMD tab)when the CWD becomes inaccessible?
I suppose it won't matter until you activate it and try to do something with it.

I did manage (almost) instantaneous notification and automatic fallback to another directory with a plugin.
Code:
v:\> cwdcheck /?
CWDCHECK [1 (on) | 0 (off) | fallback_dir (sticky, changeable, implies 1)]
- with no args, status
It polls in a thread. With a polling interval of 2 seconds, it took 51 minutes before I could detect an increase in TCC's CPU time, and then, the increase was about 1/10 sec (and I cannot definitely attribute all of that increase to CWDCHECK). But I still am uneasy about the whole idea ... using any resources on something that happens once in a blue moon (and for many/most users, never).
 
May 20, 2008
3,520
3
Elkridge, MD, USA
If one of the systems on your LAN is a laptop, it walks away easily without notifying the other systems in advance. Another frequent situation is a removable (real or virtual) drive on another system mapped to a local drive letter.
BTW, I have no issue with using a plug-in for this task - TCC is a large and wonderful toolbox, but it does not need to have all the tools in the world. This kind of extension is exactly what plug-ins are intended for.
 
May 20, 2008
9,195
60
Syracuse, NY, USA
If one of the systems on your LAN is a laptop, it walks away easily without notifying the other systems in advance. Another frequent situation is a removable (real or virtual) drive on another system mapped to a local drive letter.
BTW, I have no issue with using a plug-in for this task - TCC is a large and wonderful toolbox, but it does not need to have all the tools in the world. This kind of extension is exactly what plug-ins are intended for.
It's in a private version of my little-touted 4THREADS plugin. I'll post a version here if you want to try it. But I must ask ... do you want it to generate Ctrl-C when it finds the CWD invalid and automatically changes to a fallback directory? I would suppose "Yes". That has the nice effect of causing a new prompt to appear (if you're at the command line) and the break could be handled before a batch file went on to some other error.
 
May 20, 2008
9,195
60
Syracuse, NY, USA
I would appreciate it.
Do you still have the old one? The only one I found that seemed complete had the following help screen. Can you tell me if that's it? And I even found an obvious bug in that one ... if you asked for %WW_EVENT, it had CREATE and DESTROY reversed!
Code:
WATCHWIN [/C|/D] id  command  [class_regex  [caption_regex]]
 
/C - CREATE only; /D - DESTROY only; these affect all watches and
can only be set with the first watch
 
Default regex: "."; quote args with spaces; \" = literal quote
 
These variables exist for the duration of "command":
 
        WW_EVENT (CREATE/DESTROY), WW_ID, WW_TIME, WW_HANDLE
 
        with CREATE also WW_PID, WW_CAPTION, WW_CLASS, WW_MODULE
 
WATCHWIN /L(ist) [id_regex]
 
WATCHWIN /K(ill) [id_regex]