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

Re: P modify in history event



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.

pws

diff --git a/Src/hist.c b/Src/hist.c
index fd5606dc3..e47be8e15 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -920,6 +920,16 @@ histsubchar(int c)
 	    case 'u':
 		sline = casemodify(sline, CASMOD_UPPER);
 		break;
+	    case 'P':
+		if (*sline != '/') {
+		    char *here = zgetcwd();
+		    if (here[strlen(here)-1] != '/')
+			sline = zhtricat(metafy(here, -1, META_HEAPDUP), "/", sline);
+		    else
+			sline = dyncat(here, sline);
+		}
+		sline = xsymlink(sline, 1);
+		break;
 	    default:
 		herrflush();
 		zerr("illegal modifier: %c", c);



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