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

Re: history expansion - modifiers :h and :t - questions





On Tue, Oct 24, 2023 at 4:56 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:

The documentation for :t is being a bit too literal.  More accurate
would be to say that 0 is always the same as having no digit at all.

Does the following patch make sense?  This applies to both h and t modifiers.
t already references h as to what actions digits have on the two modifiers and
the exception t has.

diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index 837a85db6..6de49bff6 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -276,7 +276,8 @@ substitution tt($var:h2) is treated as tt(${var:h}2), not as
 tt(${var:h2}).  No restriction applies to the use of digits in history
 substitution or globbing qualifiers.  If more components are requested
 than are present, the entire path is substituted (so this does not
-trigger a `failed modifier' error in history expansion).
+trigger a `failed modifier' error in history expansion).  0 is treated
+the same as if there were no digits.
 )
 item(tt(l))(
 Convert the words to all lowercase.
@@ -342,7 +343,7 @@ Remove all leading pathname components, leaving the final component (tail).
 This works like `tt(basename)'.  Any trailing slashes are first removed.
 Decimal digits are handled as described above for (h), but in this
 case that number of trailing components is preserved instead of
-the default 1; 0 is treated the same as 1.
+the default 1.
 )
 item(tt(u))(
 Convert the words to all uppercase.

Just a thought.  Thanks.

Regards,

Jim Murphy


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