From 15430ba3ab0336dfb01c7a727df08bae9c5f37e8 Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Thu, 30 Sep 2010 00:46:02 +0000 Subject: [PATCH] small fix in distro id to handle incorrectly arch linux /etc/lsb-release file. Normally we won't fix such things, which are just bugs in the distro, but in this case, since there's now an overall failsafe, that can be used for all future distros that might make the same mistake. But please, tighten up your standards distro, this is a small file, and it's not hard to fill it out right, is it? Or is it? --- inxi | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/inxi b/inxi index 56cfb77..295eedd 100755 --- a/inxi +++ b/inxi @@ -1,7 +1,7 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 1.4.17 +#### version: 1.4.18 #### Date: September 29 2010 ######################################################################## #### SPECIAL THANKS @@ -2255,9 +2255,27 @@ get_distro_lsb_data() distroCodename = $NF " " } } + # sometimes some distros cannot do their lsb-release files correctly, so here is + # one last chance to get it right. + /^DISTRIB_DESCRIPTION/ { + gsub(/^ +| +$/, "", $0) + if ( $NF != "n/a" ) { + # slice out the part inside "", like: DISTRIB_DESCRIPTION="Arch Linux" + gsub(/DISTRIB_DESCRIPTION=|"/,"",$0) + distroDescription = $0 + } + } END { - print distroId distroRelease distroCodename - }' $FILE_LSB_RELEASE ) + fullString="" + if ( distroId == "" && distroRelease == "" && distroCodename == "" && distroDescription != "" ){ + fullString = distroDescription + } + else { + fullString = distroId distroRelease distroCodename + } + print fullString + } + ' $FILE_LSB_RELEASE ) log_function_data 'cat' "$FILE_LSB_RELEASE" fi # this is HORRIBLY slow, but I don't know why, it runs fast in shell