Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion pkgsearch
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,19 @@ has -v fzf gawk || die
request="$*"

if [[ -r /etc/os-release ]]; then
distro=$(awk -F'=' '"NAME" == $1 { gsub("\"", "", $2); print tolower($2); }' /etc/os-release)
# Attempt to get ID_LIKE from os-release to capture the "flavor" of the distro
# If ID_LIKE is not available, defer to ID
# If ID is not available, defer to NAME
distro=$(awk -F= '
$1=="ID_LIKE" { gsub(/"/,"",$2); idlike=$2 }
$1=="ID" { gsub(/"/,"",$2); id=$2 }
$1=="NAME" { gsub(/"/,"",$2); name=$2 }
END {
if (idlike) print tolower(idlike)
else if (id) print tolower(id)
else if (name) print tolower(name)
}
' /etc/os-release)
distro="${distro%% *}"
fi

Expand Down