1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-12 18:59:50 +03:00

main/zsh: backport fix for completion for manpages

fixes: https://gitlab.alpinelinux.org/alpine/aports/-/issues/16713
This commit is contained in:
Natanael Copa 2025-01-17 12:19:15 +01:00
parent fd3d6c494a
commit 8cd1045733
2 changed files with 87 additions and 1 deletions

View file

@ -0,0 +1,84 @@
From 1e52cd968d7ffd9da3249ef01f6c41f8b29e4df3 Mon Sep 17 00:00:00 2001
From: Bart Schaefer <schaefer@zsh.org>
Date: Sun, 22 May 2022 15:50:45 -0700
Subject: [PATCH] 50278: use `man -w` in preference to `manpath`; fix caching
and precedence of -M
---
ChangeLog | 5 ++++
Completion/Unix/Command/_man | 45 ++++++++++++++++++++++--------------
2 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man
index dba1d13dc..190811e41 100644
--- a/Completion/Unix/Command/_man
+++ b/Completion/Unix/Command/_man
@@ -16,7 +16,7 @@
_man() {
local dirs expl mrd awk variant noinsert
local -a context line state state_descr args modes
- local -aU sects
+ local -aU sects _manpath
local -A opt_args val_args sect_descs
if [[ $service == man ]]; then
@@ -168,29 +168,40 @@ _man() {
_arguments -s -S : $args '*::: :->man' && return 0
[[ -n $state ]] || return 1
+ # Override man path
+ [[ -n ${opt_args[-M]} ]] &&
+ _manpath=( ${(s<:>)opt_args[-M]} )
+
+ # Restore cached man path to avoid $(manpath) if we can
if (( ! $#_manpath )); then
- local mp
- mp=( ${(s.:.)$(manpath 2>/dev/null)} )
- [[ "$mp" == *:* ]] && mp=( ${(s.:.)mp} )
- if (( $#mp )); then
- _manpath=( $mp )
- elif (( $#manpath )); then
- _manpath=( $manpath )
+ if (( ! $+_manpath_cache )); then
+ typeset -gHA _manpath_cache
fi
+ if [[ -z $_manpath_cache[$MANPATH] ]]; then
+ local mp
+ mp=( ${(s.:.)$({ command man -w || manpath } 2>/dev/null)} )
+ [[ "$mp" == *:* ]] && mp=( ${(s.:.)mp} )
+ if (( $#mp )); then
+ _manpath_cache[$MANPATH]=${(j.:.)mp}
+ elif (( $#manpath )); then
+ _manpath_cache[$MANPATH]=$MANPATH
+ fi
+ fi
+ _manpath=( ${(s.:.)_manpath_cache[$MANPATH]} )
+ fi
+
+ # Augment man path
+ if [[ -n ${opt_args[-m]} ]]; then
+ [[ $variant == (netbsd|openbsd)* ]] &&
+ _manpath+=( ${(s<:>)opt_args[-m]} )
+ elif [[ $variant == aix* ]]; then
+ # _manpath declared -U so no need to test
+ _manpath+=( /usr/share/man )
fi
(( $#_manpath )) ||
_manpath=( /usr/man(-/) /(opt|usr)/(pkg|dt|share|X11R6|local)/(cat|)man(-/) )
- # Override man path
- [[ -n ${opt_args[-M]} ]] &&
- _manpath=( ${(s<:>)opt_args[-M]} )
-
- # Augment man path
- [[ $variant == (netbsd|openbsd)* ]] &&
- [[ -n ${opt_args[-m]} ]] &&
- _manpath+=( ${(s<:>)opt_args[-m]} )
-
# `sman' is the SGML manual directory for Solaris 7.
# 1M is system administrator commands on SVR4
--
2.48.1

View file

@ -13,7 +13,7 @@
#
pkgname=zsh
pkgver=5.9
pkgrel=4
pkgrel=5
pkgdesc="Very advanced and programmable command interpreter (shell)"
url="https://www.zsh.org/"
arch="all"
@ -43,6 +43,7 @@ source="https://sourceforge.net/projects/zsh/files/zsh/$pkgver/zsh-$pkgver.tar.x
zsh-newuser-install-alpine.patch
fix-gcc14-incompatible-pointer-types.patch
implicit.patch
0001-50278-use-man-w-in-preference-to-manpath-fix-caching.patch
zprofile
zshenv
zshrc
@ -212,6 +213,7 @@ d9138b7f379ad942a5f46819d2dd52d31f3a1129f2a0d1b53d4c5cd43c318b60396da6d37c57c477
3be36a30af2c33c5d4d0412acd30fbb52fbaad49c692f12ab1a9c57d87cee62ad0b4737127585e2dc5824b98428ff097977f610a4d1fa3d83c9370b7cf2956f7 zsh-newuser-install-alpine.patch
905562600f157ae745d837a9c2e2790dc373ee151b9b05c50e59862473db20f356e7aea528452fbfb1ddf2e3b985f6959b7850884c3218ece6232a679f210997 fix-gcc14-incompatible-pointer-types.patch
0fd193a92c24dfd3b97f6294469cad8c799c91c27bb1f298bb64dcd10982543e80ab9e63517915ff648096e85105044c9d2d4368977266f7e3f6b34e69277768 implicit.patch
0cda29109164fb798f26cc6c6492915569373c8316a8bf10979ec1d8551495dd89978a2231190be29aab4ab6dd90a8fe0c236ffcc82e11f98165328e0a387a3f 0001-50278-use-man-w-in-preference-to-manpath-fix-caching.patch
66a6bdf8d915c818a2c31c35c90c2a19f91d15e2d8547d050e980ef63080f27033ef1f59da5befb30dbf46050ce907690a680e48db11711d40930420f7ec1c2b zprofile
e1c40649c940b91fb6dbcf9e7878e3c96d3729c8eee7b97cfe007d14d19add500863cef588ea4818ab83921fef9f9b4384c2003b26e9d753a8d59e9aca837d43 zshenv
a7f4f5267cf0a9d1e0c480e89ede0811435803e4822b522dfc0326a9015a44af5e3163160b5595dc055acfca28f56811521c728e020389c7a5e4e0e4b3811d38 zshrc