Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Omission of colon in !!:n history expansion



Hello everyone,

I was scouring the documentation earlier today and realised that the
history expansion pattern that I've been using for quite a few years
is... Undocumented.

I'm referring here to:

    !!n

Where <n> is any sequence of digits.

Here's the relevant excerpt from the documentation in question:

> A word designator indicates which word or words of a given command
> line are to be included in a history reference.  A ‘:' usually
> separates the event specification from the word designator.  It may be
> omitted only if the word designator begins with a ‘^', ‘$', ‘*',
> ‘-' or ‘%'. Word designators include:

Ref: zshexpn > HISTORY EXPANSION > Word Designators

It is extremely similar to the equivalent section regarding history
expansion in the Bash manual.

However, in Bash, !!:n would indeed be the only variant that would
designate "the second word from the previous command":

    bash                  zsh
    ----                  ---

    $ echo a b c          % echo a b c
    a b c                 a b c
    $ echo !!2            % echo !!2
    echo a b c2           b

I didn't quite attempt to locate the corresponding implementation in the
source code to hunt down any clue as to whether that is intentional--I
sure hope that this behaviour is here to stay either way.

If it is indeed here to stay, could we then adopt it fully, in
mentioning that in the documentation?  If so, I'd be happy to submit a
patch :-)

Is here even the best place to ask?  I wouldn't be offended if I were
told to first go through the procedure I admitted having skipped, in
tracking down the intent of the implementer(s) at the time.

-- 
Eric NICOLAS




Messages sorted by: Reverse Date, Date, Thread, Author