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

Re: [PATCH] hist, subst: add :R modifier for readlink(2)



On Mon 6 Apr 2026, at 17:41, Bart Schaefer wrote:
> Is it really OK for this to fail when not HAVE_READLINK ?
>
> That is, to print an error, as opposed to act like :P would.

i didn't think about that. you're just suggesting the change below
right?

your reply + something mikael said on irc have me second-guessing the
whole thing, though, because now i'm not sure there's an obviously /
generically correct thing to do when it can't resolve

returning the input makes sense for :[aAP] because those are meant to
produce a usable path (or at least one that's as usable as the input),
and that operation is inherently transformative. but here the point is
to get the link target *verbatim*. having it substitute the input when
that's not possible seems weird/annoying for many use cases

it could return an empty string instead, like `zstat +link` does, but
that's weird in its own way, especially for globquals

unless someone else thinks it's an especially great idea i'll probably
just leave it alone after all

dana


diff --git a/Src/hist.c b/Src/hist.c
index 5f528ec78..1a9c0306d 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -1893,6 +1893,10 @@ chreadlink(char **junkptr)
     ssize_t len;
     char buf[PATH_MAX];
 
+#ifndef HAVE_READLINK
+    return 1;
+#endif
+
     if (!**junkptr)
 	return 1;
 




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