zsh-users
 help / color / mirror / code / Atom feed
* "history" modifier question
@ 2023-05-04  6:32 Jim
  2023-05-05  0:19 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Jim @ 2023-05-04  6:32 UTC (permalink / raw)
  To: zsh

[-- Attachment #1: Type: text/plain, Size: 782 bytes --]

Hello,

Trying to use history modifier 'h [ digit ]' (the following also applies to
't [digit ]'),where digit is a scalar or integer, ( e.g. ${PWD:h${N}} ) to
step
through a path via a loop, but this doesn't appear to be allowed. Tried
multiple ways of doing this including quoting.

This seems like a logical use of a parameter, but 'my' logic, sometimes,
doesn't match reality.

Is there a way of doing this or is this just not possible. If not could
someone
tell me why, I would like to understand what I'm missing here. The man
page, AFAICT, doesn't say  one way or the other if this is possible. Unless,
"digit" is explicit here.

FYI, I did come up with an alternative method by using an array and split.

ZSH_VERSION: 5.9

Thanks for your time, and with regards,

Jim Murphy

[-- Attachment #2: Type: text/html, Size: 1120 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: "history" modifier question
  2023-05-04  6:32 "history" modifier question Jim
@ 2023-05-05  0:19 ` Bart Schaefer
  2023-05-05  0:50   ` Jim
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2023-05-05  0:19 UTC (permalink / raw)
  To: linuxtechguy; +Cc: zsh

On Wed, May 3, 2023 at 11:32 PM Jim <linux.tech.guy@gmail.com> wrote:
>
> Trying to use history modifier 'h [ digit ]' (the following also applies to
> 't [digit ]'),where digit is a scalar or integer, ( e.g. ${PWD:h${N}} )

You can do it like this:  ${(e):-\${PWD:h${N}}}

> I would like to understand what I'm missing here. The man
> page, AFAICT, doesn't say  one way or the other if this is possible. Unless,
> "digit" is explicit here.

Yes, the digit following :h has to be a literal digit, not an expansion.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: "history" modifier question
  2023-05-05  0:19 ` Bart Schaefer
@ 2023-05-05  0:50   ` Jim
  0 siblings, 0 replies; 3+ messages in thread
From: Jim @ 2023-05-05  0:50 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh

[-- Attachment #1: Type: text/plain, Size: 478 bytes --]

On Thu, May 4, 2023 at 7:19 PM Bart Schaefer <schaefer@brasslantern.com>
wrote:

>
> You can do it like this:  ${(e):-\${PWD:h${N}}}
>
> Yes that works, Thanks.
    e Perform single word shell expansions,
Had to think about that for a second, but got it. Learned my something new
for
today. :-)

Yes, the digit following :h has to be a literal digit, not an expansion.
>

Darn, it would have been nice, but your example is just fine.

Regards,

Jim Murphy

[-- Attachment #2: Type: text/html, Size: 1058 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-05  0:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-04  6:32 "history" modifier question Jim
2023-05-05  0:19 ` Bart Schaefer
2023-05-05  0:50   ` Jim

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).