diff options
| author | Daniel Shahaf <d.s@daniel.shahaf.name> | 2025-05-14 14:52:41 +0000 |
|---|---|---|
| committer | Daniel Shahaf <d.s@daniel.shahaf.name> | 2025-05-14 14:53:12 +0000 |
| commit | 5db0d046b65a464f9be3560ab4eb298cd30864a1 (patch) | |
| tree | 3f4e2cf3bfd5579ea4af33dfe23d45547a7ecc8b /Src/utils.c | |
| parent | 53524 (cf. 53607): Add an XFAIL test for a 'whence -s' bug involving non-syml... (diff) | |
| download | zsh-5db0d046b65a464f9be3560ab4eb298cd30864a1.tar zsh-5db0d046b65a464f9be3560ab4eb298cd30864a1.tar.gz zsh-5db0d046b65a464f9be3560ab4eb298cd30864a1.tar.bz2 zsh-5db0d046b65a464f9be3560ab4eb298cd30864a1.tar.lz zsh-5db0d046b65a464f9be3560ab4eb298cd30864a1.tar.xz zsh-5db0d046b65a464f9be3560ab4eb298cd30864a1.tar.zst zsh-5db0d046b65a464f9be3560ab4eb298cd30864a1.zip | |
53607: Stop printing /usr/bin/foo -> /usr/bin/foo in 'whence -s'.
Makes the new test PASS.
Review-by: Bart Schaefer
Diffstat (limited to 'Src/utils.c')
| -rw-r--r-- | Src/utils.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Src/utils.c b/Src/utils.c index 19fd61a8b..4ea7b8e93 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -1003,11 +1003,23 @@ print_if_link(char *s, int all) } } } else { - if (chrealpath(&s, 'P', 0)) { +#ifdef HAVE_MEMCCPY + char s_at_entry[PATH_MAX+1]; + if (!memccpy(s_at_entry, s, '\0', sizeof(s_at_entry))) { + DPUTS1(1, "path longer than PATH_MAX: %s", s); + s_at_entry[PATH_MAX] = '\0'; + } +#else /* HAVE_MEMCCPY */ + char *s_at_entry = ztrdup(s); +#endif /* HAVE_MEMCCPY */ + if (chrealpath(&s, 'P', 0) && strcmp(s, s_at_entry)) { printf(" -> "); zputs(*s ? s : "/", stdout); zsfree(s); } +#ifndef HAVE_MEMCCPY + zsfree(s_at_entry); +#endif /* !HAVE_MEMCCPY */ } } } |
