From: Ian Kelling Date: Mon, 20 May 2024 22:07:09 +0000 (-0400) Subject: slightly more robust X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;ds=inline;h=HEAD;p=distro-functions slightly more robust --- diff --git a/src/identify-distros b/src/identify-distros index fa66172..88b31fc 100644 --- a/src/identify-distros +++ b/src/identify-distros @@ -53,15 +53,15 @@ distro-name-ver() { } distro-num() { - # Subshell keeps environment clean. - ( . /etc/os-release - # in ubuntu the .x matters, trisquel it doesnt - if [[ $ID == ubuntu ]]; then - echo $VERSION_ID - else - echo ${VERSION_ID%%.*} - fi - ) + local os_id ver_id + os_id=$(awk -F = '$1 == "ID" { print $2 }' /etc/os-release) + ver_id=$(awk -F = '$1 == "VERSION_ID" { print $2 }' /etc/os-release | sed 's/"//g') + # of VERSION_ID.x, the x matters in ubuntu but not trisquel + if [[ $os_id == ubuntu ]]; then + printf "%s\n" "$ver_id" + else + printf "%s\n" "$ver_id" | sed 's/\..*//' + fi } debian-archive() {