1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PRE_EXEC?

Discussion in 'Support' started by vefatica, Jul 14, 2013.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,888
    Likes Received:
    30
    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.
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,809
    Likes Received:
    82
    No.
     
  3. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    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?
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,888
    Likes Received:
    30
    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).
     
  5. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    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.
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,888
    Likes Received:
    30
    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.
     
  7. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,888
    Likes Received:
    30
  8. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    Did you drop WATCHWIN intentionally or accidentally?
     
  9. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,888
    Likes Received:
    30
    That can't happen accidentally though I don't remember removing it. Do you miss it? I still have a few source files representing a few versions of WATCHWIN and could probably resurrect it.
     
  10. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,523
    Likes Received:
    4
    I would appreciate it.
     
  11. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,888
    Likes Received:
    30
    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]
     

Share This Page