From 831dbe4e6c5929435d42ee6aed11f410e40c4fc0 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Mon, 20 May 2024 18:07:09 -0400 Subject: [PATCH] slightly more robust --- src/identify-distros | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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() { -- 2.30.2