status

statusbar program for dwm
git clone anongit@rnpnr.xyz:status.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 63d7d4f772f4c2961335ac24ef54e541bb4b4d9f
Parent: e7df6ef301f72cfc09be5941c6f479f2e9592c1a
Author: Randy Palamar
Date:   Thu,  8 Sep 2022 13:38:44 -0600

script.c: correctly trim newlines

Diffstat:
Mblocks/script.c | 6++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/blocks/script.c b/blocks/script.c @@ -14,11 +14,9 @@ script(struct Block *b) if ((fp = popen(b->u.s, "r")) == NULL) die("popen()\n"); - fgets(buf, sizeof(buf), fp); + if (fgets(buf, sizeof(buf), fp) != NULL) + buf[strcspn(buf, "\n")] = 0; pclose(fp); - if (buf[strlen(buf) - 1] == '\n') - buf[strlen(buf) - 1] = 0; - return snprintf(b->curstr, LEN(b->curstr), b->fmt, buf); }