• where is "!" documented for history package?

    From clt.to.davebr@dfgh.net@21:1/5 to All on Mon Dec 26 15:34:16 2022
    I recently tried naming two procs "mon" and "!mon".
    In most cases executing !mon on the console executed mon.
    It appears this is a feature of the history package,
    however I'm not finding any mention of it in the manual page.
    Does anyone know where it is documented?

    daveb

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to clt.to.davebr@dfgh.net on Mon Dec 26 17:00:38 2022
    clt.to.davebr@dfgh.net wrote:
    I recently tried naming two procs "mon" and "!mon".
    In most cases executing !mon on the console executed mon.
    It appears this is a feature of the history package,
    however I'm not finding any mention of it in the manual page.
    Does anyone know where it is documented?

    The exclamation point for history expansion is used by GNU readline, so
    if the history package is generally trying to emulate readline, that
    would be where to look for documentation.

    The docs for ! in the bash manpage are:

    Event Designators
    An event designator is a reference to a command line entry in
    the history list. Unless the reference is absolute, events are
    relative to the current position in the history list.

    ! Start a history substitution, except when followed by a
    blank, newline, carriage return, = or ( (when the extglob
    shell option is enabled using the shopt builtin).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ashok@21:1/5 to clt.to.davebr@dfgh.net on Tue Dec 27 08:22:22 2022
    On 12/26/2022 9:04 PM, clt.to.davebr@dfgh.net wrote:
    I recently tried naming two procs "mon" and "!mon".
    In most cases executing !mon on the console executed mon.
    It appears this is a feature of the history package,
    however I'm not finding any mention of it in the manual page.
    Does anyone know where it is documented?

    daveb


    Good question. I could not find it documented in the Tcl manpages either.

    Of course, the Unix shell pages document it so you could use that as a
    (rough) reference. Still, this tclsh feature is not Unix-specific and
    should probably be documented if it isn't.

    /Ashok

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Schelte@21:1/5 to clt.to.davebr@dfgh.net on Tue Dec 27 10:40:29 2022
    On 26/12/2022 16:34, clt.to.davebr@dfgh.net wrote:
    I recently tried naming two procs "mon" and "!mon".
    In most cases executing !mon on the console executed mon.
    It appears this is a feature of the history package,

    This is not a feature of the history package. It is the `unknown`
    command that jumps in when a command line does not match an existing
    command. So the behavior is described in the unknown man page:
    "First, it sees if cmd has one of the following three forms: !!, !event,
    or ^old^new?^?. If so, then unknown carries out history substitution in
    the same way that csh would for these constructs."

    However, if you have defined a !mon proc, then that should always be
    found and the `unknown` command would not be invoked. I have no
    explanation for the behavior you describe.


    Schelte.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From clt.to.davebr@dfgh.net@21:1/5 to All on Tue Dec 27 15:05:15 2022
    The odd behavior occured while using the tkcon (version 2.7) console on Slackware Linux.
    When I used tclsh or wish, the proc named !mon worked as expected.
    I should have included the test enviroment info in my initial question.

    tclsh:

    % package require history
    0.1
    % proc mon {} {return 11}
    % proc !mon {} {return 22}
    % mon
    11
    % !mon
    22
    %


    tkcon:

    (try) 49 % proc mon {} {return 11}
    (try) 50 % proc !mon {} {return 22}
    (try) 51 % mon
    11
    (try) 52 % !mon
    mon
    11

    It appears this is a feature of tkcon.
    I've used up and down arrows to access history in tkcon.
    This is the first time I've noticed differences in how tkcon and tclsh or wish interpret the command line text though.

    daveb

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From saitology9@21:1/5 to clt.to.davebr@dfgh.net on Tue Dec 27 13:19:38 2022
    On 12/27/2022 10:05 AM, clt.to.davebr@dfgh.net wrote:
    The odd behavior occured while using the tkcon (version 2.7) console on Slackware Linux.
    ...

    It appears this is a feature of tkcon.
    I've used up and down arrows to access history in tkcon.
    This is the first time I've noticed differences in how tkcon and tclsh or wish
    interpret the command line text though.

    tkcon does its own thing with command input before sending it to the interpreter for evaluation. Observe:

    % proc mon {} {return 11}
    % proc !mon {} {return 22}

    % !mon
    no event matches "mon"

    You can see it treats the leading "!" as a symbol for its own purposes
    and it searches for a matching command in its history. It stops there
    without any further action.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)