pacman -Q resolves provider names, so dropping a virtual package could remove whichever package provides it. Read pacman -Qq once and match requested names exactly, ignoring providers and duplicate arguments. Ports the provider-ignoring semantics of 9791b227 from master with a single pacman query instead of one per package. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
25 lines
570 B
Bash
Executable File
25 lines
570 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Remove all the named packages from the system if they're installed (otherwise ignore).
|
|
# omarchy:args=<packages...>
|
|
# omarchy:requires-sudo=true
|
|
|
|
installed=()
|
|
declare -A installed_exact=()
|
|
declare -A selected=()
|
|
|
|
while IFS= read -r package_name; do
|
|
installed_exact[$package_name]=1
|
|
done < <(pacman -Qq)
|
|
|
|
for pkg in "$@"; do
|
|
if [[ -n ${installed_exact[$pkg]} && -z ${selected[$pkg]} ]]; then
|
|
installed+=("$pkg")
|
|
selected[$pkg]=1
|
|
fi
|
|
done
|
|
|
|
if (( ${#installed[@]} > 0 )); then
|
|
sudo pacman -Rns --noconfirm "${installed[@]}"
|
|
fi
|