paleofetch

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

commit b1f3dcfc4d4d3ccb74c411617ade0ba8443f13bd
parent a246f8329e0578ed046afa0b75e46a41395a0fa1
Author: sam-barr <samfbarr@outlook.com>
Date:   Thu, 23 Apr 2020 16:34:02 -0500

Merge pull request #34 from dwzg/fix_os

Fix OS detection on Debian 10 and other distros
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);