Skip to content

Commit a86f885

Browse files
committed
Reverse the order by which variables are populated
On Arch Linux, when asking for the description, we get it: $ ./lsb_release -d Description: Arch Linux But when we ask for the codename of the release as well, the description is set to "(none)". $ ./lsb_release -d -c Description: (none) Codename: n/a This happens because when we request the codename, in GetDistribInfo(), we trigger the InitDistribInfo() logic when -c is given. This overrides the DISTRIB_DESCRIPTION variable that has been parsed from /etc/lsb-release. However, according to lsb_release/src/lsb_release.examples: Optional fields are DISTRIB_ID, DISTRIB_RELEASE, DISTRIB_CODENAME, DISTRIB_DESCRIPTION and can be used to override information which is parsed from the "/etc/distrib-release" file. This means that we're actually invoking GetLSBInfo() and GetDistribInfo() in reverse order. We should invoke GetDistribInfo() first so that it can be overridden by GetLSBInfo() later. Reverse the calling order of these two functions. Since we've reversed the calling order, GetDistribInfo() will never have any of the variables populated when it's called so remove the checks for those.
1 parent 4db6950 commit a86f885

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

lsb_release/src/lsb_release

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@
5151
# - changed Debian specifics, codename anticipates release num
5252
#
5353
# Description:
54-
# Collect information from sourceable /etc/lsb-release file (present on
55-
# LSB-compliant systems) : LSB_VERSION, DISTRIB_ID, DISTRIB_RELEASE,
56-
# DISTRIB_CODENAME, DISTRIB_DESCRIPTION (all optional)
54+
# Find and parse the /etc/[distro]-release file
55+
# Collect information from sourceable /etc/lsb-release file for overriding
56+
# (present on LSB-compliant systems) : LSB_VERSION, DISTRIB_ID,
57+
# DISTRIB_RELEASE, DISTRIB_CODENAME, DISTRIB_DESCRIPTION (all optional)
5758
# Then (if needed) find and add names from /etc/lsb-release.d
58-
# Then (if needed) find and parse the /etc/[distro]-release file
5959

6060

6161
###############################################################################
@@ -274,13 +274,7 @@ EASE ($DISTRIB_CODENAME)"
274274

275275
# Check missing and requested infos, then find the file and get infos
276276
GetDistribInfo() {
277-
NO="" # /etc/lsb-release data are enough to reply what is requested?
278-
[ -n "$ARG_D" ] && [ -z "$DISTRIB_DESCRIPTION" ] && NO="y"
279-
[ -z "$NO" ] && [ -n "$ARG_I" ] && [ -z "$DISTRIB_ID" ] && NO="y"
280-
[ -z "$NO" ] && [ -n "$ARG_R" ] && [ -z "$DISTRIB_RELEASE" ] && NO="y"
281-
[ -z "$NO" ] && [ -n "$ARG_C" ] && [ -z "$DISTRIB_CODENAME" ] && NO="y"
282-
283-
if [ -n "$NO" ]
277+
if [ -n "$ARG_D" ] || [ -n "$ARG_I" ] || [ -n "$ARG_R" ] || [ -n "$ARG_C" ]
284278
then
285279
if [ ! -f "$CHECKFIRST" ]
286280
then
@@ -410,8 +404,8 @@ then
410404
fi
411405

412406
# Initialization
413-
GetLSBInfo
414407
GetDistribInfo
408+
GetLSBInfo
415409

416410
# Display requested infos (order as follow)
417411
[ -n "$ARG_V" ] && DisplayVersion

0 commit comments

Comments
 (0)