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

WAD PRE_EXEC executed before PROMPT2

Discussion in 'Support' started by vefatica, Jul 29, 2016.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    Code:
    v:\> set prompt2
    PROMPT2=$e[32;1m+$g$s$e[0m
    
    v:\> alias pre_exec echo foo
    
    v:\> do i=1 to 3 (
    foo
    +> echo %i )
    1
    2
    3
    
    v:\>
     
    #1 vefatica, Jul 29, 2016
    Last edited: Jul 29, 2016
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,804
    Likes Received:
    82
    WAD.

    PRE_EXEC is executed after the original line has been entered. The parser subsequently determines (much later) that the line is incomplete, and prompts for the remainder. If PRE_EXEC were delayed until the line continuation, it would break a LOT of existing functionality (including aliases). And it would require a significant parser rewrite -- for AFAICT no discernible benefit.
     
  3. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,188
    Likes Received:
    11
    What is PROMPT2 ?
     
  4. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,804
    Likes Received:
    82
    The prompt that's displayed if you have a continued line (i.e., an escape at the EOL, or an open command group).

    I.e., a feature that scarcely anybody uses. Including Vince.
     
    #4 rconn, Jul 29, 2016
    Last edited: Jul 30, 2016
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,883
    Likes Received:
    29
    I'm surprised that you can't move the test that triggers the execution of PRE_EXEC to one (or more) more appropriate locations (namely, just before execution of the command).

    Maybe its name should be changed (to, say, POST_ENTER), and its description changed to better reflect what it does.
     
  6. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,804
    Likes Received:
    82
    I could, if you promise me that nobody will ever enter a compound command, pipe, or conditional command. Or a command group.
     

Share This Page