Improve safety and CLI fidelity for everyday use
Drop default --noconfirm (opt-in via --noconfirm), fix --noremovemake, forward pacman argv intact for -R/-D/-F/-T/-U, deepen PKGBUILD review, show an install plan before building, and add shellcheck CI plus unit tests. Co-authored-by: Frank Vitrano <WHC2006@users.noreply.github.com>
This commit is contained in:
co-authored by
Frank Vitrano
parent
d0f2cfe335
commit
bba71040d6
+30
-25
@@ -108,7 +108,9 @@ cmd_interactive() {
|
||||
done
|
||||
|
||||
if [[ ${#repo_pkgs[@]} -gt 0 ]]; then
|
||||
as_root ${MIAUR_PACMAN} -S --needed --noconfirm "${repo_pkgs[@]}"
|
||||
local -a conf=()
|
||||
mapfile -t conf < <(pac_noconfirm_args)
|
||||
as_root ${MIAUR_PACMAN} -S --needed "${conf[@]}" "${repo_pkgs[@]}"
|
||||
fi
|
||||
if [[ ${#aur_pkgs[@]} -gt 0 ]]; then
|
||||
install_aur_packages "${aur_pkgs[@]}"
|
||||
@@ -154,7 +156,9 @@ cmd_sync_install() {
|
||||
done
|
||||
|
||||
if [[ ${#repo_pkgs[@]} -gt 0 ]]; then
|
||||
as_root ${MIAUR_PACMAN} -S --needed --noconfirm "${repo_pkgs[@]}"
|
||||
local -a conf=()
|
||||
mapfile -t conf < <(pac_noconfirm_args)
|
||||
as_root ${MIAUR_PACMAN} -S --needed "${conf[@]}" "${repo_pkgs[@]}"
|
||||
fi
|
||||
if [[ ${#aur_pkgs[@]} -gt 0 ]]; then
|
||||
install_aur_packages "${aur_pkgs[@]}"
|
||||
@@ -185,30 +189,18 @@ cmd_getpkgbuild() {
|
||||
cmd_clean() {
|
||||
# -Sc: clean pacman cache + AUR clone cache
|
||||
if [[ ${MIAUR_MODE:-} != aur ]]; then
|
||||
as_root ${MIAUR_PACMAN} -Sc --noconfirm || true
|
||||
local -a conf=()
|
||||
mapfile -t conf < <(pac_noconfirm_args)
|
||||
as_root ${MIAUR_PACMAN} -Sc "${conf[@]}" || true
|
||||
fi
|
||||
aur_clean_cache
|
||||
}
|
||||
|
||||
dispatch() {
|
||||
# Full passthrough ops (R, D, F, T, U, or unknown)
|
||||
if [[ $DO_PASSTHRU -eq 1 && $OP != S && $OP != Q ]]; then
|
||||
# Rebuild approximate pacman command from original? Simpler: use saved extras
|
||||
local -a args=()
|
||||
case "$OP" in
|
||||
R) args+=(-R) ;;
|
||||
*)
|
||||
# Fall back: user should use pacman; try to forward
|
||||
args+=(-"${OP}")
|
||||
;;
|
||||
esac
|
||||
local c
|
||||
for c in "${PACMAN_EXTRA[@]}"; do
|
||||
args+=("-$c")
|
||||
done
|
||||
args+=("${TARGETS[@]}")
|
||||
pacman_passthru "${args[@]}"
|
||||
return $?
|
||||
# Passthrough for R/D/F/T/U is handled in main() via strip_miaur_opts.
|
||||
# Keep a reconstruction fallback only if somehow reached without orig argv.
|
||||
if [[ $DO_PASSTHRU -eq 1 && $OP != S && $OP != Q && $OP != G && $OP != B && $OP != interactive ]]; then
|
||||
die "internal error: passthrough should be handled in main"
|
||||
fi
|
||||
|
||||
case "$OP" in
|
||||
@@ -233,9 +225,11 @@ dispatch() {
|
||||
fi
|
||||
if [[ $OP_UPGRADE -eq 1 ]]; then
|
||||
need_cmd curl jq
|
||||
local -a conf=()
|
||||
mapfile -t conf < <(pac_noconfirm_args)
|
||||
if [[ $OP_AUR_ONLY -eq 1 ]]; then
|
||||
# -Sua or -Su --aur
|
||||
[[ $OP_REFRESH -eq 1 ]] && as_root ${MIAUR_PACMAN} -Sy --noconfirm
|
||||
[[ $OP_REFRESH -eq 1 ]] && as_root ${MIAUR_PACMAN} -Sy "${conf[@]}"
|
||||
cmd_upgrade_aur
|
||||
else
|
||||
cmd_upgrade_all "$OP_REFRESH"
|
||||
@@ -243,11 +237,17 @@ dispatch() {
|
||||
return
|
||||
fi
|
||||
if [[ $OP_REFRESH -eq 1 && ${#TARGETS[@]} -eq 0 ]]; then
|
||||
as_root ${MIAUR_PACMAN} -Sy --noconfirm
|
||||
local -a conf=()
|
||||
mapfile -t conf < <(pac_noconfirm_args)
|
||||
as_root ${MIAUR_PACMAN} -Sy "${conf[@]}"
|
||||
return
|
||||
fi
|
||||
# Install packages; optionally refresh first
|
||||
[[ $OP_REFRESH -eq 1 ]] && as_root ${MIAUR_PACMAN} -Sy --noconfirm
|
||||
if [[ $OP_REFRESH -eq 1 ]]; then
|
||||
local -a conf=()
|
||||
mapfile -t conf < <(pac_noconfirm_args)
|
||||
as_root ${MIAUR_PACMAN} -Sy "${conf[@]}"
|
||||
fi
|
||||
need_cmd curl jq
|
||||
cmd_sync_install "${TARGETS[@]}"
|
||||
;;
|
||||
@@ -268,7 +268,12 @@ dispatch() {
|
||||
local -a qargs=(-Q)
|
||||
local c
|
||||
for c in "${PACMAN_EXTRA[@]}"; do
|
||||
qargs+=("-$c")
|
||||
# Long options like --explicit may land in PACMAN_EXTRA as full tokens
|
||||
if [[ $c == --* ]]; then
|
||||
qargs+=("$c")
|
||||
else
|
||||
qargs+=("-$c")
|
||||
fi
|
||||
done
|
||||
[[ $OP_AUR_ONLY -eq 1 ]] && qargs+=(-m)
|
||||
[[ $OP_SEARCH -gt 0 ]] && qargs+=(-s)
|
||||
|
||||
Reference in New Issue
Block a user