paleofetch

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 166a418d3c1166b3f8272a66d9d3e72a1590f25f
parent a246f8329e0578ed046afa0b75e46a41395a0fa1
Author: dwzg <dennis@wtzg.de>
Date:   Thu, 23 Apr 2020 23:18:41 +0200

Fix OS detection on Debian 10 and other distros

Debian has the NAME value in /etc/os-release on the second line.
Parse through /etc/os-release line for line until NAME is found.

Diffstat:
Mpaleofetch.c | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/paleofetch.c b/paleofetch.c @@ -104,14 +104,20 @@ char *get_bar() { char *get_os() { char *os = malloc(BUF_SIZE), - *name = malloc(BUF_SIZE); + *name = malloc(BUF_SIZE), + *line = NULL; + size_t len; FILE *os_release = fopen("/etc/os-release", "r"); if(os_release == NULL) { status = -1; halt_and_catch_fire("unable to open /etc/os-release"); } - fscanf(os_release, "NAME=\"%[^\"]+", name); + while (getline(&line, &len, os_release) != -1) { + if (sscanf(line, "NAME=\"%[^\"]+", name) > 0) break; + } + + free(line); fclose(os_release); snprintf(os, BUF_SIZE, "%s %s", name, uname_info.machine); free(name);