From 865d2d8a53f65eba22c8a0436be1ea985aaa2aba Mon Sep 17 00:00:00 2001 From: ratijas Date: Tue, 8 Dec 2020 00:00:25 +0300 Subject: [PATCH] refactor(archlinux): prevent leaking local variables (#9476) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Marc Cornellà --- plugins/archlinux/archlinux.plugin.zsh | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/plugins/archlinux/archlinux.plugin.zsh b/plugins/archlinux/archlinux.plugin.zsh index 4d39bd86b..c72e06dc2 100644 --- a/plugins/archlinux/archlinux.plugin.zsh +++ b/plugins/archlinux/archlinux.plugin.zsh @@ -171,14 +171,13 @@ function paclist() { } function pacdisowned() { - emulate -L zsh - + local tmp db fs tmp=${TMPDIR-/tmp}/pacman-disowned-$UID-$$ db=$tmp/db fs=$tmp/fs mkdir "$tmp" - trap 'rm -rf "$tmp"' EXIT + trap 'rm -rf "$tmp"' EXIT pacman -Qlq | sort -u > "$db" @@ -189,15 +188,14 @@ function pacdisowned() { } function pacmanallkeys() { - emulate -L zsh curl -s https://www.archlinux.org/people/{developers,trustedusers}/ | \ awk -F\" '(/pgp.mit.edu/) { sub(/.*search=0x/,""); print $1}' | \ xargs sudo pacman-key --recv-keys } function pacmansignkeys() { - emulate -L zsh - for key in $*; do + local key + for key in $@; do sudo pacman-key --recv-keys $key sudo pacman-key --lsign-key $key printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \ @@ -207,13 +205,13 @@ function pacmansignkeys() { if (( $+commands[xdg-open] )); then function pacweb() { - pkg="$1" - infos="$(LANG=C pacman -Si "$pkg")" + local pkg="$1" + local infos="$(LANG=C pacman -Si "$pkg")" if [[ -z "$infos" ]]; then return fi - repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')" - arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')" + local repo="$(grep -m 1 '^Repo' <<< "$infos" | grep -oP '[^ ]+$')" + local arch="$(grep -m 1 '^Arch' <<< "$infos" | grep -oP '[^ ]+$')" xdg-open "https://www.archlinux.org/packages/$repo/$arch/$pkg/" &>/dev/null } fi