]> granicus.if.org Git - procps-ng/commitdiff
top: do not add an extra line when rcfile is rewritten
authorJim Warner <james.warner@comcast.net>
Tue, 15 Mar 2022 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Mon, 21 Mar 2022 20:43:56 +0000 (07:43 +1100)
When the configuration file is first written, there is
just the normal single newline which ends that rcfile.

However, when any existing rcfile was rewritten, there
was one extra newline '\n' character added at the end.
This will happen just once. The file does NOT continue
to grow with the extra blank lines always being added.

Anyway, this patch will put an end to such a practice.

Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.c

index 5a91080d93c2cc137c8dd25b2690c4f44b4137f2..0dc55581de454bb9915938654badb31342aebb64 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -5281,7 +5281,7 @@ static void write_rcfile (void) {
       fprintf(fp, Osel_delim_2_txt);
    }
 
-   if (Inspect.raw)
+   if (Inspect.raw && strcmp(Inspect.raw, "\n"))
       fputs(Inspect.raw, fp);
 
    fclose(fp);