From 6e69f1ee0f3ee12bf544d0598b57af1fcff24a56 Mon Sep 17 00:00:00 2001 From: Ruediger Meier Date: Thu, 8 May 2014 19:01:03 +0200 Subject: [PATCH] last: avoid leading "-" before "no logout" This affects option --time-format=notime. Signed-off-by: Ruediger Meier --- login-utils/last.c | 5 ++++- tests/expected/last/last | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/login-utils/last.c b/login-utils/last.c index 3a802eda6d..ba58c44338 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -465,9 +465,12 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t t, int wh if (ctl->time_fmt > LAST_TIMEFTM_SHORT_CTIME) { sprintf(logouttime, " gone - no logout"); length[0] = 0; - } else { + } else if (ctl->time_fmt == LAST_TIMEFTM_SHORT_CTIME) { sprintf(logouttime, " gone"); sprintf(length, "- no logout"); + } else { + logouttime[0] = 0; + sprintf(length, "no logout"); } break; case R_REBOOT: diff --git a/tests/expected/last/last b/tests/expected/last/last index 9dbee127a3..4172e8697a 100644 --- a/tests/expected/last/last +++ b/tests/expected/last/last @@ -90,7 +90,7 @@ accounti foo nine Wed Aug 28 03:00:00 2013 - Wed Aug 28 04: wtmp begins Wed Aug 28 03:00:00 2013 ~~~ no time ~~~ rick long never-gonna-logo (24855+03:14) -torvalds linux hobby - no logout +torvalds linux hobby no logout reboot system boot system-name running reboot system boot system-name (01:00) IPv4 root dns-server (01:00) -- 2.47.2