Fix Linux distribution identification through /etc/os-release#179
Merged
scaronni merged 1 commit intodkms-project:masterfrom Nov 17, 2021
Merged
Fix Linux distribution identification through /etc/os-release#179scaronni merged 1 commit intodkms-project:masterfrom
scaronni merged 1 commit intodkms-project:masterfrom
Conversation
On Linux distributions such as Arch Linux, /etc/os-release contains:
NAME="Arch Linux"
PRETTY_NAME="Arch Linux"
ID=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://archlinux.org/"
DOCUMENTATION_URL="https://wiki.archlinux.org/"
SUPPORT_URL="https://bbs.archlinux.org/"
BUG_REPORT_URL="https://bugs.archlinux.org/"
LOGO=archlinux-logo
There is no `ID_LIKE` property, so `${#ID_LIKE[@]}` is zero:
$ . /etc/os-release
$ echo ${#ID_LIKE[@]}
0
As `0` is not empty, `[[ ${#ID_LIKE[@]} ]]` is true:
$ [[ ${#ID_LIKE[@]} ]] ; echo $?
0
So in `dkms`, the function `distro_version` returns an empty string in
[[ ${#ID_LIKE[@]} ]] && echo ${ID_LIKE[0]} || echo $ID
Fix this by replacing `[[ ${#ID_LIKE[@]} ]]` with `[[ ${#ID_LIKE[@]} != 0]]`.
Fixes: f0b11ce ("dkms: rework distribution detection")
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Linux distributions such as Arch Linux,
/etc/os-releasecontains:There is no
ID_LIKEproperty, so${#ID_LIKE[@]}is zero:As
0is not empty,[[ ${#ID_LIKE[@]} ]]is true:So in
dkms, the functiondistro_versionreturns an empty string inFix this by replacing
[[ ${#ID_LIKE[@]} ]]with[[ ${#ID_LIKE[@]} != 0]].Fixes: f0b11ce ("dkms: rework distribution detection")