zsh-users
 help / color / mirror / code / Atom feed
From: "Daniel Shahaf" <d.s@daniel.shahaf.name>
To: zsh-users@zsh.org
Subject: Re: P modify in history event
Date: Tue, 19 Nov 2019 18:00:08 +0000	[thread overview]
Message-ID: <d64df0bd-0ebb-4f5b-af63-cab62dfbd5fb@www.fastmail.com> (raw)
In-Reply-To: <1574070429.4551.2.camel@samsung.com>

Peter Stephenson wrote on Mon, 18 Nov 2019 09:47 +00:00:
> On Sun, 2019-11-17 at 12:42 -0600, Perry Smith wrote:
> > I’m (slowly) reading through zshexpn and playing with things to
> > learn.  This does not work:
> > 
> > > 
> > > pedz@MysticSlate my-play-dir % echo /this/is/a/../../path
> > > /this/is/a/../../path
> > > pedz@MysticSlate my-play-dir % echo !$:P
> > > zsh: illegal modifier: P
> > even if the file specified exists
> 
> I think it just got missed out of the history modifiers, which are
> handled in a different place from the modifiers in the case of glob
> qualifiers and vaariables.

Thanks for fixing this.  Test added in 030440d5b7bfd2968138836e962f1ef61ea0bae8.

> +++ b/Src/hist.c
> @@ -920,6 +920,16 @@ histsubchar(int c)
> +	    case 'P':
> +		if (*sline != '/') {
> +		    char *here = zgetcwd();
> +		    if (here[strlen(here)-1] != '/')

Can «zgetcwd()» return an empty string?  If that's possible, the
condition will be undefined behaviour («""[-1]»).

> +			sline = zhtricat(metafy(here, -1, META_HEAPDUP), "/", sline);
> +		    else
> +			sline = dyncat(here, sline);
> +		}
> +		sline = xsymlink(sline, 1);
> +		break;

Cheers,

Daniel

  reply	other threads:[~2019-11-19 18:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20191117184333epcas5p15bc1aa7b0f78182c3d1acc703f55d445@epcas5p1.samsung.com>
2019-11-17 18:42 ` Perry Smith
2019-11-18  9:47   ` Peter Stephenson
2019-11-19 18:00     ` Daniel Shahaf [this message]
2019-11-19 18:21       ` Peter Stephenson
2019-11-19 19:03         ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d64df0bd-0ebb-4f5b-af63-cab62dfbd5fb@www.fastmail.com \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).