in JetBrains.HabitatDetector/src/OsReleaseProperties.cs [89:112]
internal static OsReleaseProperties ReadFromStream(StreamReader reader)
{
// Note(ww898): See https://www.linux.org/docs/man5/os-release.html and https://www.freedesktop.org/software/systemd/man/os-release.html
static bool IsQuotedString(string str, char ch) => str.Length >= 2 && str[0] == ch && str[str.Length - 1] == ch;
var properties = new Dictionary<string, string>();
for (string? line; (line = reader.ReadLine()) != null;)
{
line = line.TrimEnd();
if (line.Length == 0 || line[0] == '#')
continue;
var n = line.IndexOf('=');
if (n < 0)
throw new FormatException();
var key = line.Substring(0, n);
var value = line.Substring(n + 1);
properties[key] = IsQuotedString(value, '\'') || IsQuotedString(value, '"')
? value.Substring(1, value.Length - 2)
: value;
}
return new OsReleaseProperties(properties);
}