[Bug 795346] /etc/os-release parser fails on comments or empty lines

GStreamer (GNOME Bugzilla) bugzilla at gnome.org
Wed Apr 18 15:01:16 UTC 2018


https://bugzilla.gnome.org/show_bug.cgi?id=795346

--- Comment #6 from Peter Marquardt <wwwutz at gmail.com> ---
(In reply to Olivier CrĂȘte from comment #4)
> Which distro has comments in its /etc/os-release ? Can you attach the file
> here so whoever writes a patch can test against it?

Hmmm... as you said, comments are valid. To be honest, empty lines are not
mentioned. So we cannot really support them. The parser should stop immediately
when it reads an empty line. Maybe tell the user to contact his distro to fix
it. maybe force a system upgrade in background to see if this has been fixed
already.

Anyways, I don't think we want to discuss the format of /etc/os-release of
distro xyz or force a patch writer to install distro xyz for testing purposes,
would we ?

sudo echo "#" > /etc/os-release

... would be the first thing he should try for testing 8-) "creating your own
distro for dummies - page 12"

open I,'<','/etc/os-release' or die;
while(<I>){
  /^\s*#.*//;
  /^\s*$/ and next;
  /(\S+)\s*=\s*(.*)\s*/ and $V{$1}=$2;  
}
close(I);

untested code in an 80s language ("writing pseudo code in ancient languages -
national geograhics, book 314, page 1592") 

or maybe, for testing purposes, create a local copy of /etc/os-release via "cp
/etc/os-release os-release" and change the code by deleting the "/etc" part of
the filename. There might be a python module for "cp".

sorry, I don't want to troll, but hey: this program parses a text file of a
couple of lines, and we are discussing "valid formats" ? give me a break.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list