From: Jim Warner Date: Tue, 15 Mar 2022 05:00:00 +0000 (-0500) Subject: top: do not add an extra line when rcfile is rewritten X-Git-Tag: v4.0.3_rc1~33^2~74 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a03a09ae1e69e48037c7329414b0c27fe26fc407;p=procps-ng top: do not add an extra line when rcfile is rewritten 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 --- diff --git a/top/top.c b/top/top.c index 5a91080d..0dc55581 100644 --- 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);