From 99dc9a4ef523ddf180b88063c4cfbc9cd516d79c Mon Sep 17 00:00:00 2001 From: fatalerrors Date: Thu, 9 Jul 2026 18:17:53 +0200 Subject: [PATCH] get rid of eval (use readarray) --- profile.d/compress.sh | 8 ++++++-- profile.d/conf.sh | 4 +++- profile.d/debug.sh | 4 +++- profile.d/disp.sh | 4 +++- profile.d/filefct.sh | 28 +++++++++++++++++++++------- profile.d/fun.sh | 12 +++++++++--- profile.d/git.sh | 42 ++++++++++++++++++++++++++++++------------ profile.d/info.sh | 18 +++++++++++++----- profile.d/lang.sh | 4 +++- profile.d/packages.sh | 8 ++++++-- profile.d/processes.sh | 24 ++++++++++++++++++------ profile.d/pwd.sh | 4 +++- profile.d/rain.sh | 4 +++- profile.d/ssh.sh | 4 +++- profile.d/updates.sh | 8 ++++++-- 15 files changed, 130 insertions(+), 46 deletions(-) diff --git a/profile.d/compress.sh b/profile.d/compress.sh index 4300966..5b54e4e 100644 --- a/profile.d/compress.sh +++ b/profile.d/compress.sh @@ -189,7 +189,9 @@ utaz() disp E "Invalid options, use \"utaz --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) @@ -599,7 +601,9 @@ taz() disp E "Invalid options, use \"taz --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" local compforms=() while true; do case "$1" in diff --git a/profile.d/conf.sh b/profile.d/conf.sh index 2e209a9..c73760a 100755 --- a/profile.d/conf.sh +++ b/profile.d/conf.sh @@ -177,7 +177,9 @@ conf_dump() disp E "Invalid options, use \"conf_dump --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in diff --git a/profile.d/debug.sh b/profile.d/debug.sh index 48f33d7..8b4e132 100644 --- a/profile.d/debug.sh +++ b/profile.d/debug.sh @@ -73,7 +73,9 @@ settrace() disp E "Invalid options, use \"settrace --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" # First pass: gather the requested action and flags. --on, --off and # --status are mutually exclusive; --force only modifies --on. diff --git a/profile.d/disp.sh b/profile.d/disp.sh index 0297371..a14a0a2 100644 --- a/profile.d/disp.sh +++ b/profile.d/disp.sh @@ -595,7 +595,9 @@ mdcat() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) diff --git a/profile.d/filefct.sh b/profile.d/filefct.sh index 7f666d5..1461ae8 100644 --- a/profile.d/filefct.sh +++ b/profile.d/filefct.sh @@ -49,7 +49,9 @@ expandlist() disp E "Invalid options, use \"expandlist --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in @@ -138,7 +140,9 @@ clean() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in @@ -264,7 +268,9 @@ rmspc() disp E "Invalid options, use \"rmspc --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in @@ -388,7 +394,9 @@ file_stats() disp E "Invalid options, use \"file_stats --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in @@ -616,7 +624,9 @@ findbig() disp E "Invalid options, use \"findbig --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in @@ -721,7 +731,9 @@ findzero() disp E "Invalid options, use \"findzero --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in @@ -819,7 +831,9 @@ finddead() disp E "Invalid options, use \"finddead --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in diff --git a/profile.d/fun.sh b/profile.d/fun.sh index b4f3daa..5599be9 100644 --- a/profile.d/fun.sh +++ b/profile.d/fun.sh @@ -55,7 +55,9 @@ busy() disp E "Invalid options, use \"busy --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in @@ -142,7 +144,9 @@ fake_compile() disp E "Invalid options, use \"fake_compile --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in @@ -325,7 +329,9 @@ hack() disp E "Invalid options, use \"hack --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in diff --git a/profile.d/git.sh b/profile.d/git.sh index b1e922f..511be09 100644 --- a/profile.d/git.sh +++ b/profile.d/git.sh @@ -95,7 +95,9 @@ gst() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) @@ -142,7 +144,9 @@ ggraph() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" local limit=30 while true; do case "$1" in @@ -193,7 +197,9 @@ gsync() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) @@ -248,7 +254,9 @@ gacp() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" local msg="" auto_add=0 case "${GIT_GACP_AUTO_ADD,,}" in 1|true|yes|on) auto_add=1 ;; @@ -366,7 +374,9 @@ greset() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" local clean_ignored=0 while true; do case "$1" in @@ -482,7 +492,9 @@ gwip() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) @@ -525,9 +537,9 @@ export -f gwip # (git branch --merged). # Deep mode (-D/--deep): additionally deletes branches whose tracking remote # has disappeared (remote pruned after a merge request / pull request merge). -# Those branches are detected via `git fetch --prune` + remote-tracking gone. +# Those branches are detected via 'git fetch --prune' + remote-tracking gone. # This is the common case when the MR was merged upstream and the remote -# branch was deleted by the forge. Deletion uses `git branch -D` (force) +# branch was deleted by the forge. Deletion uses 'git branch -D' (force) # because the local branch has no merged ancestor that git can verify locally. gprune() { @@ -539,7 +551,9 @@ gprune() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) @@ -583,7 +597,7 @@ gprune() [[ $b == "master" || $b == "main" || $b == "develop" || $b == "dev" ]] && continue git branch -d "$b" >/dev/null 2>&1 && { printf "Deleted (merged): %s\n" "$b" - deleted=$((deleted+1)) + deleted=$(( deleted+1 )) } done < <(git branch --merged "$base" | sed -E 's/^\*?\s*//') @@ -598,16 +612,18 @@ gprune() [[ $b == "$current" ]] && continue [[ $b == "$base" ]] && continue [[ $b == "master" || $b == "main" || $b == "develop" || $b == "dev" ]] && continue + # Detect a gone upstream without relying on localized "gone]" text: # resolve the branch's upstream, then check its remote-tracking ref. upstream=$(git rev-parse --abbrev-ref "${b}@{upstream}" 2>/dev/null) || true [[ -z "$upstream" ]] && continue # no tracking branch at all — skip + # If the remote-tracking ref still exists, the upstream is not gone. git show-ref --verify --quiet "refs/remotes/$upstream" 2>/dev/null && continue sha=$(git rev-parse --short "$b" 2>/dev/null) git branch -D "$b" >/dev/null 2>&1 && { printf "Deleted (gone upstream): %s (%s)\n" "$b" "$sha" - deleted=$((deleted+1)) + deleted=$(( deleted+1)) } done < <(git for-each-ref --format='%(refname:short)' refs/heads/) fi @@ -631,7 +647,9 @@ groot() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" local do_go=0 while true; do case "$1" in diff --git a/profile.d/info.sh b/profile.d/info.sh index 960ed48..a16d4f0 100644 --- a/profile.d/info.sh +++ b/profile.d/info.sh @@ -50,7 +50,9 @@ ver() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) @@ -90,7 +92,9 @@ meteo() disp E "Invalid options, use \"meteo --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) @@ -146,7 +150,9 @@ pinfo() disp E "Invalid options, use \"pinfo --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) @@ -311,7 +317,7 @@ pinfo() # /proc/bus/pci/devices col 1 is busdevfn, col 2 is vendorID<<16|deviceID # The class 0x03xx is "Display controller / VGA compatible" case "$_pci_name" in - *VGA*|*Display*|*3D*|*GPU*|*Graphics*|*Radeon*|*GeForce*|*Intel*Iris*|*Intel*UHD*|*Intel*HD*Graphics*) + *VGA*|*Display*|*3D*|*GPU*|*Graphics*|*Radeon*|*GeForce*|*Intel*Iris*|*Intel*UHD*|*Intel*HD*) gpu_list+=("$_pci_name") ;; esac @@ -364,7 +370,9 @@ showinfo() disp E "Invalid options, use \"showinfo --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in diff --git a/profile.d/lang.sh b/profile.d/lang.sh index 1dab605..35e867e 100644 --- a/profile.d/lang.sh +++ b/profile.d/lang.sh @@ -95,7 +95,9 @@ setlocale() disp E "Invalid options, use \"setlocale --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) diff --git a/profile.d/packages.sh b/profile.d/packages.sh index 97ff94c..b7afed2 100644 --- a/profile.d/packages.sh +++ b/profile.d/packages.sh @@ -133,7 +133,9 @@ pkgs() disp E "Invalid options, use \"pkgs --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in @@ -209,7 +211,9 @@ pkgf() disp E "Invalid options, use \"pkgf --help\" to display usage." return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in diff --git a/profile.d/processes.sh b/profile.d/processes.sh index 6b50389..1bda577 100644 --- a/profile.d/processes.sh +++ b/profile.d/processes.sh @@ -51,7 +51,9 @@ ppg() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) @@ -116,7 +118,9 @@ ppu() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) @@ -164,7 +168,9 @@ ppn() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) @@ -214,7 +220,9 @@ gpid() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) @@ -296,7 +304,9 @@ ku() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) @@ -421,7 +431,9 @@ kt() return 1 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) diff --git a/profile.d/pwd.sh b/profile.d/pwd.sh index 51e0a01..cd2cc74 100644 --- a/profile.d/pwd.sh +++ b/profile.d/pwd.sh @@ -69,7 +69,9 @@ genpwd() -n 'genpwd' -- "$@") # shellcheck disable=SC2181 # getopt return code is checked immediately after if [[ $? -ne 0 ]]; then return 1; fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in diff --git a/profile.d/rain.sh b/profile.d/rain.sh index 14fe8fa..65f529e 100644 --- a/profile.d/rain.sh +++ b/profile.d/rain.sh @@ -597,7 +597,9 @@ rainbow() local frame_sleep frame_sleep=$(_rain_normalize_speed "$_raw_speed") || frame_sleep=0.040 - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help) diff --git a/profile.d/ssh.sh b/profile.d/ssh.sh index 6c911c9..20fb679 100644 --- a/profile.d/ssh.sh +++ b/profile.d/ssh.sh @@ -48,7 +48,9 @@ rmhost() PARSED=$(getopt -o ha --long help,all-users -n 'rmhost' -- "$@") # shellcheck disable=SC2181 # getopt return code is checked immediately after if [[ $? -ne 0 ]]; then return 1; fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in diff --git a/profile.d/updates.sh b/profile.d/updates.sh index 611c8c3..9bb6807 100644 --- a/profile.d/updates.sh +++ b/profile.d/updates.sh @@ -59,7 +59,9 @@ check_updates() disp E "Invalid options, use \"check_updates --help\" to display usage." return 2 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in @@ -139,7 +141,9 @@ profile_upgrade() disp E "Invalid options, use \"profile_upgrade --help\" to display usage." return 2 fi - eval set -- "$PARSED" + local -a _pargs=() + readarray -td '' _pargs < <(printf '%s' "$PARSED" | xargs printf '%s\0') + set -- "${_pargs[@]}" while true; do case "$1" in -h|--help)