Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Document colonless numeric history expansion word designators
- X-seq: zsh-workers 55240
- From: Éric NICOLAS <ccjmne@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [PATCH] Document colonless numeric history expansion word designators
- Date: Mon, 2 Nov 2026 00:09:11 +0100
- 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-20260327; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=iKz2go1EWXcdQRDcduLOg0PE8xw5BJ3WT2AezzGvXK8=; fh=SbTlPuNNxBzTkRlwWtqw/TXBY0HvGvtE97RpPp3sJPM=; b=Zlse1xVuadfqbJxfBdoiHE+gzu9YQaOelnK4gUA3y2kh2AjhMZQ+nK3OzoeKEpIpMP /em3SfI7Tb2D7VoL7DwQVqWjplapEoV0R7d75w9df7B0GACajsTNlO8yHkBsV0BhYk2b G3+6QVE7Tpf0jVz+X82iRaiYabG5l3m8JZvC7Z9jn/aQAOagQryhIphRG40RmhVNOPot r16xG3NDh7uTJ461y2wB9cDbPZM+GRcEhlMusHnHMFa2MZ7YTnEMO54OFm1mopm4FAhc lkFKthD3DKN1AuY3Q0iA9pVVc+Xa5wrwqIs+4ka5x3ida/HqcRKfzvYArkd+ewaJPVYo JU5Q==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1793574562; cv=none; d=google.com; s=arc-20260327; b=IQ3y2Bm2MpzL468icvAb+WxrE2uI04QbFr/590Kkuy27ZvRky5QLeuKNelyqLkCIT0 zTsrb2CWvbuXRFhDGIrtdEa3C8u9ZDBWGFyz9WtzNc05YM/scQIvv7Fs1iBVdLATXqza bw3L7SyoLedERGUNJeH40CJhTncNg0cPaoQiWDtz/joo86Z5z+lr28IT4U14aov09GSy sDAuuihLSEcJup81lERSZMqcTC0BdsnvBrzmFJ0yQCAEJPDneJmLQWD5xBcsI+sc69Qh O8KsKLcUl4Hw2Ggeb1kAvVBqPhJlo/3HrjM0jYuh2BdtySW1UmjSSqJGHyJ+vvPnixnu AqBA==
- Archived-at: <https://zsh.org/workers/55240>
- In-reply-to: <20260906171155.1935101-1-ccjmne@gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <20260906171155.1935101-1-ccjmne@gmail.com>
Following up on this documentation patch. Could someone review whether
documenting the existing colonless numeric word-designator behaviour is
acceptable?
The patch includes the implementation-history reference and regression test.
If there’s a concern about treating this behaviour as supported, I’d
appreciate knowing that too.
You can find the patch in question at: https://zsh.org/workers/55134
Thanks.
On Sun, 6 Sept 2026 at 19:12, Éric NICOLAS <ccjmne@xxxxxxxxx> wrote:
>
> Using history expansion, the implementation of Zsh allows the omission
> of the colon before some numeric word designators, following:
>
> !!, !#, and !?str?, for example !!2, !#1, and !?test?4:t.
>
> The implementation has been exhibiting that behaviour since the earliest
> revision in this Git repository, with e74702b46 (Initial revision,
> 1999-04-15), but the manual currently says that the colon may only be
> omitted before:
>
> ^, $, *, -, or %.
>
> For example, you may very well do:
>
> mkdir /tmp/asdf && cd !#1
>
> Document the long-standing behaviour and introduce test coverage.
>
> ---
> I wrote to the zsh-users mailing list in April this year, asking for
> confirmation this behaviour is intended and here to stay.
>
> This patch proposes to document that behaviour, which has been in place
> throughout the entire recorded history of Zsh's source.
>
> For reference, here's my thread: https://www.zsh.org/mla/users/2026/msg00148.html
> ---
> Doc/Zsh/expn.yo | 7 +++++--
> Test/W01history.ztst | 14 ++++++++++++++
> 2 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
> index c5995f4e4..86edcddd0 100644
> --- a/Doc/Zsh/expn.yo
> +++ b/Doc/Zsh/expn.yo
> @@ -184,8 +184,11 @@ cindex(word designators, history)
> A word designator indicates which word or words of a given command line are
> to be included in a history reference. A `tt(:)' usually
> separates the event specification from the word designator.
> -It may be omitted only if the word designator begins with a
> -`tt(^)', `tt($)', `tt(*)', `tt(-)' or `tt(%)'.
> +It may be omitted if the word designator begins with a `tt(^)', `tt($)',
> +`tt(*)', `tt(-)' or `tt(%)'. A numeric word designator may also omit the colon
> +after `tt(!!)', `tt(!#)', or a `tt(!?)var(str)tt(?)' event designator, for
> +example `tt(!!3)', `tt(!#3)' or `tt(!?)var(str)tt(?3)'. Note that `tt(!3)'
> +refers to event 3 rather than word 3 of the previous event.
> Word designators include:
>
> startsitem()
> diff --git a/Test/W01history.ztst b/Test/W01history.ztst
> index 665a37f2c..272b5a435 100644
> --- a/Test/W01history.ztst
> +++ b/Test/W01history.ztst
> @@ -18,6 +18,20 @@
> >one two three four five six seven eight nine ten
> >print one two three four five six seven eight nine ten one two
>
> + PS1= $ZTST_testdir/../Src/zsh -fis <<<'
> + print huey dewey louie
> + print !!2
> + print /tmp/asdf !#1
> + print test a/one b/two c/three
> + print !?test?4:t
> + '
> +0:Numeric word references without a colon
> +>huey dewey louie
> +>dewey
> +>/tmp/asdf /tmp/asdf
> +>test a/one b/two c/three
> +>three
> +
> PS1= $ZTST_testdir/../Src/zsh -fis <<<'
> print line one of an arbitrary series
> print issue two for some mystery sequence
> --
> 2.55.0
>
--
Eric NICOLAS
Messages sorted by:
Reverse Date,
Date,
Thread,
Author