1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-14 11:41:07 +02:00

users/26579: changes from review including parameter expansion to replace awk

This commit is contained in:
Marc Chantreux 2021-03-11 19:08:57 +01:00 committed by Oliver Kiddle
parent 2c000ee7ba
commit ccc7ff90a4
2 changed files with 20 additions and 13 deletions

View file

@ -1,5 +1,8 @@
2021-04-06 Oliver Kiddle <opk@zsh.org>
* Marc Chantreux: users/26579: Completion/Unix/Command/_surfraw:
changes from review including parameter expansion to replace awk
* 48414: Completion/Unix/Type/_bpf_filters: quote closing bracket
to adapt for change in 43928

View file

@ -430,19 +430,23 @@ case $state in
esac
;;
elvi)
local -UT XDG_CONFIG_DIRS xcd
# as it starts with a space, the header becomes an empty
# string removed by the list expansion
_wanted elvi expl elvi compadd \
${${(f)"$(surfraw -elvi)"}%%[[:space:]]*} $(
# extract the keys of all bookmarks (should be in surfraw itself)
awk '{keys[$1]=1} END {for (k in keys) print k}' \
$^xcd/surfraw/bookmarks(Nr) \
/etc/xdg/surfraw/bookmarks(Nr) \
/etc/surfraw.bookmarks(Nr) \
${XDG_CONFIG_HOME-${HOME?homeless}/.config}/surfraw/bookmarks(Nr) \
${HOME?homeless}/.surfraw.bookmarks(Nr)
) && ret=0
local -UT XDG_CONFIG_DIRS xdg_config_dirs
local it
# list the applets
set -- ${${(f)"$(_call_program elvi surfraw -elvi)"}%%[[:space:]]##-- *}
shift # the first line is an header: remove it
# then list the bookmarks
for it in \
$^xdg_config_dirs/surfraw/bookmarks(Nr) \
/etc/xdg/surfraw/bookmarks(Nr) \
/etc/surfraw.bookmarks(Nr) \
${XDG_CONFIG_HOME-$HOME/.config}/surfraw/bookmarks(Nr) \
$HOME/.surfraw.bookmarks(Nr)
do
read -d'\0' it < $it
set -- "$@" ${${(f)it}%%[[:space:]]*}
done
_wanted elvi expl elvi compadd "$@" && ret=0
;;
esac