]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
last: --time-format=full should do the same like -F
authorRuediger Meier <ruediger.meier@ga-group.nl>
Thu, 8 May 2014 15:45:31 +0000 (17:45 +0200)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Thu, 8 May 2014 20:14:06 +0000 (22:14 +0200)
For no reason "full" did something else than "iso" or -F as you
see here:
$ ./last  -f ../tests/ts/last/wtmp.LE  --time-format=full  | grep -A2 "no logout"
torvalds linux        hobby            Mon Aug 26 02:57:08 1991    gone                    - no logout
reboot   system boot  system-name      Wed Aug 28 20:00:00 2013   still                    running
reboot   system boot  system-name      Wed Aug 28 18:00:00 2013 - Wed Aug 28 19:00:00 2013  (01:00)
$ ./last  -f ../tests/ts/last/wtmp.LE  --time-format=iso  | grep -A2 "no logout"
torvalds linux        hobby            1991-08-26T02:57:08+0200   gone - no logout
reboot   system boot  system-name      2013-08-28T20:00:00+0200   still running
reboot   system boot  system-name      2013-08-28T18:00:00+0200 - 2013-08-28T19:00:00+0200  (01:00)
$ ./last  -f ../tests/ts/last/wtmp.LE  -F  | grep -A2 "no logout"
torvalds linux        hobby            Mon Aug 26 02:57:08 1991   gone - no logout
reboot   system boot  system-name      Wed Aug 28 20:00:00 2013   still running
reboot   system boot  system-name      Wed Aug 28 18:00:00 2013 - Wed Aug 28 19:00:00 2013  (01:00)

Also note the useless leading space before "gone"

The only thing which matters is fmt->out width when printing these
strings like "still running". Now ctl->fulltime flag is unsused and
removed.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
login-utils/last.c

index 7029963cc151fc278767f07c4099dab900638689..6935464031cf4ea8f84ac5b7d07951c7a2afdcac 100644 (file)
@@ -82,8 +82,7 @@ struct last_control {
                     showhost :1, /* Show hostname */
                     altlist :1,  /* Hostname at the end */
                     usedns :1,   /* Use DNS to lookup the hostname */
-                    useip :1,    /* Print IP address in number format */
-                    fulltime :1; /* Print full dates and times */
+                    useip :1;    /* Print IP address in number format */
 
        unsigned int name_len;  /* Number of login name characters to print */
        unsigned int domain_len; /* Number of domain name characters to print */
@@ -434,7 +433,7 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t t, int wh
 
        epoch = time(NULL);
        if (t == epoch) {
-               if (ctl->fulltime) {
+               if (ctl->time_fmt > LAST_TIMEFTM_SHORT_CTIME) {
                        sprintf(logouttime, "  still running");
                        length[0] = 0;
                } else {
@@ -455,7 +454,7 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t t, int wh
                        break;
                case R_NOW:
                        length[0] = 0;
-                       if (ctl->fulltime)
+                       if (ctl->time_fmt > LAST_TIMEFTM_SHORT_CTIME)
                                sprintf(logouttime, "  still logged in");
                        else {
                                sprintf(logouttime, "  still");
@@ -464,7 +463,7 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t t, int wh
                        break;
                case R_PHANTOM:
                        length[0] = 0;
-                       if (ctl->fulltime)
+                       if (ctl->time_fmt > LAST_TIMEFTM_SHORT_CTIME)
                                sprintf(logouttime, "  gone - no logout");
                        else {
                                sprintf(logouttime, "   gone");
@@ -932,7 +931,6 @@ int main(int argc, char **argv)
                        ctl.altlist = 1;
                        break;
                case 'F':
-                       ctl.fulltime = 1;
                        ctl.time_fmt = LAST_TIMEFTM_FULL_CTIME;
                        break;
                case 'p':
@@ -962,8 +960,6 @@ int main(int argc, char **argv)
                        break;
                case OPT_TIME_FORMAT:
                        ctl.time_fmt = which_time_format(optarg);
-                       if (ctl.time_fmt == LAST_TIMEFTM_ISO8601)
-                               ctl.fulltime = 1;
                        break;
                default:
                        usage(stderr);