Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Omission of colon in !!:n history expansion
- X-seq: zsh-users 30562
- From: ccjmne <ccjmne@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Omission of colon in !!:n history expansion
- Date: Tue, 14 Apr 2026 00:17:29 +0200
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:to:subject:message-id:date:from :mime-version:dkim-signature; bh=ImQDJFUR2WLfiSeMmpyYtj3PqisMx63wf2nodhf79nk=; fh=yk3c4scJWo86Za4IR1HBNZw2a+GkUkfVQ7Fs3jnanfg=; b=PL5p/sB9fe3lOpe5+m4J3XmZiNZRrsEjx6QY6dvDlqBESi9Iq0PeuoX01Dna8s4IWi o3d3zsPn8AyPCxHc0Mf6oL9vkaUPYZ2vmHg2Q+75IgWG4MkP3EJ1oZ4E3y8T7cvQNgqC cLAUCgwSTQO/laoNs6boDWPVeB3wlGFUKBHkEnIasIVkVPCRbAXi8i0lOsIg7AOG0hvR eqK4sgPxiMO845bDIODM1u9QP4PjRL85iKEQZIlcOvcyNwRVnA8v+BmXrGlRdLHvI41i 5OJrj4zXqoKr4IVbhgemd4iZX42CCsgx/MJQVL/EVqFTvx+a9g4R5RlhgA8Yqmflyu56 qs/Q==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1776118660; cv=none; d=google.com; s=arc-20240605; b=ERklT7Q0odDOlgcfRCFp73qfst5axCcDdxNTWu7s4COtEzhMFBgtlu02nQ/HffmXsP EhGg51vcrBYOalAFqzc9LVgxlxERG4pc+xikqafDc4MEe6fsYNvWte9EBNjp/ZJuVeZM KsNst2HBtmxBZBPryB9Ehj9VO4EfExIjxPBGP1n2ND1ranO0LRCBuXSUkIs20Kg7wWnb ImMi8bvSU+UcdVcIEfN60/wASDYez7i8usdiuIlJLLzrjZOfXfdh36p5tui+bDqzdXu9 dlnCkJNZxNf94V8Qk+F+OxTgRvqzsUrim6dNZ5OaDrW+ool2SsiDZlH6PsrOkr7aKa3S 3shA==
- Archived-at: <https://zsh.org/users/30562>
- List-id: <zsh-users.zsh.org>
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