Skip to content

Commit 8c7b10e

Browse files
Shaun Princeclaude
andcommitted
fix: Resolve ShellCheck warnings and use compact if syntax
- Quote ${tmp_pid} variable (SC2086) - Separate local declaration from assignment (SC2155) - Use while-read loop instead of array assignment (SC2207) - Use compact [[ ]] && syntax for single-command if Closes #486, closes #488 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a58db86 commit 8c7b10e

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

neofetch

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,9 +1183,7 @@ get_distro() {
11831183
*"budgie"*) distro=${distro/Ubuntu/Ubuntu Budgie} ;;
11841184
*"cinnamon"*) distro=${distro/Ubuntu/Ubuntu Cinnamon} ;;
11851185
esac
1186-
if [[ -f /etc/floflis-release ]]; then
1187-
distro="Floflis"
1188-
fi
1186+
[[ -f /etc/floflis-release ]] && distro="Floflis"
11891187
fi
11901188
;;
11911189

@@ -1592,8 +1590,11 @@ get_packages() {
15921590
# Find all matching executables in PATH directories at once
15931591
OLD_PATH=$PATH
15941592
PATH+=:EOF # hack to list last PATH dir
1593+
manager_hits=()
15951594
# shellcheck disable=SC2086
1596-
manager_hits=($(printf '%s\n' ${PATH//:/\/* } 2>/dev/null | grep -Eo "$manager_pattern" 2>/dev/null))
1595+
while IFS= read -r hit; do
1596+
manager_hits+=("$hit")
1597+
done < <(printf '%s\n' ${PATH//:/\/* } 2>/dev/null | grep -Eo "$manager_pattern" 2>/dev/null)
15971598
PATH=$OLD_PATH
15981599
fi
15991600

@@ -1946,7 +1947,7 @@ get_wm() {
19461947
if [[ -O "${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY:-wayland-0}" ]]; then
19471948
if tmp_pid="$(lsof -t "${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY:-wayland-0}" 2>/dev/null)" ||
19481949
tmp_pid="$(fuser "${XDG_RUNTIME_DIR}/${WAYLAND_DISPLAY:-wayland-0}" 2>/dev/null)"; then
1949-
wm="$(ps -p ${tmp_pid} -ho comm=)"
1950+
wm="$(ps -p "${tmp_pid}" -ho comm=)"
19501951
else
19511952
# lsof may not exist, or may need root on some systems. Similarly fuser.
19521953
# On those systems we search for a list of known window managers, this can mistakenly
@@ -4839,7 +4840,8 @@ get_full_path() {
48394840
done
48404841

48414842
# Final directory.
4842-
local full_dir="$(pwd -P)/$file_name"
4843+
local full_dir
4844+
full_dir="$(pwd -P)/$file_name"
48434845

48444846
[[ -e "$full_dir" ]] && printf '%s\n' "$full_dir"
48454847
}

0 commit comments

Comments
 (0)