7 @coreutils@
/bin
/cat << EOF
8 Usage: lsb_release [options]
11 -h, --help show this help message and exit
12 -v, --version show LSB modules this system supports
13 -i, --id show distributor ID
14 -d, --description show description of this distribution
15 -r, --release show release number of this distribution
16 -c, --codename show code name of this distribution
17 -a, --all show all of the above information
18 -s, --short show requested information in short format
23 # Potential command-line options.
32 @getopt@
/bin
/getopt
--test > /dev
/null
&& rc
=$? || rc
=$?
33 if [[ $rc -ne 4 ]]; then
34 # This shouldn't happen.
35 echo "Warning: Enhanced getopt not supported, please open an issue in nixpkgs." >&2
37 # Define all short and long options.
39 LONG
=help,version
,id
,description
,release
,codename
,all
,short
42 PARSED
=`@getopt@/bin/getopt --options $SHORT --longoptions $LONG --name "$0" -- "$@"`
48 # Process each argument, and set the appropriate flag if we recognize it.
49 while [[ $# -ge 1 ]]; do
80 echo "lsb_release: unrecognized option '$1'"
81 echo "Type 'lsb_release -h' for a list of available options."
89 if [[ -e /etc
/os-release
]]; then
93 # This is e.g. relevant for the Nix build sandbox and compatible with the
94 # original lsb_release binary:
99 VERSION_CODENAME
="n/a"
103 if [[ "$version" = "0" ]] && [[ "$id" = "0" ]] && \
104 [[ "$description" = "0" ]] && [[ "$release" = "0" ]] && \
105 [[ "$codename" = "0" ]] && [[ "$all" = "0" ]]; then
106 if [[ "$OS_RELEASE_FOUND" = "1" ]]; then
107 echo "No LSB modules are available." >&2
109 if [[ "$short" = "0" ]]; then
110 printf "LSB Version:\tn/a\n"
118 # Now output the data - The order of these was chosen to match
119 # what the original lsb_release used.
122 append_short_output
() {
123 if [[ "$1" = "n/a" ]]; then
126 SHORT_OUTPUT
+=" \"$1\""
130 if [[ "$all" = "1" ]] ||
[[ "$version" = "1" ]]; then
131 if [[ "$OS_RELEASE_FOUND" = "1" ]]; then
132 if [[ "$short" = "0" ]]; then
133 echo "No LSB modules are available." >&2
135 append_short_output
"n/a"
138 if [[ "$short" = "0" ]]; then
139 printf "LSB Version:\tn/a\n"
141 append_short_output
"n/a"
146 if [[ "$all" = "1" ]] ||
[[ "$id" = "1" ]]; then
147 if [[ "$short" = "0" ]]; then
148 printf "Distributor ID:\t$NAME\n"
150 append_short_output
"$NAME"
154 if [[ "$all" = "1" ]] ||
[[ "$description" = "1" ]]; then
155 if [[ "$short" = "0" ]]; then
156 printf "Description:\t$PRETTY_NAME\n"
158 append_short_output
"$PRETTY_NAME"
162 if [[ "$all" = "1" ]] ||
[[ "$release" = "1" ]]; then
163 if [[ "$short" = "0" ]]; then
164 printf "Release:\t$VERSION_ID\n"
166 append_short_output
"$VERSION_ID"
170 if [[ "$all" = "1" ]] ||
[[ "$codename" = "1" ]]; then
171 if [[ "$short" = "0" ]]; then
172 printf "Codename:\t$VERSION_CODENAME\n"
174 append_short_output
"$VERSION_CODENAME"
178 if [[ "$short" = "1" ]]; then
179 # Output in one line without the first space:
180 echo "${SHORT_OUTPUT:1}"
183 # For compatibility with the original lsb_release:
184 if [[ "$OS_RELEASE_FOUND" = "0" ]]; then
185 if [[ "$all" = "1" ]] ||
[[ "$id" = "1" ]] || \
186 [[ "$description" = "1" ]] ||
[[ "$release" = "1" ]] || \
187 [[ "$codename" = "1" ]]; then