wall: Print time and date (rather than just time) in wall banner
PATCH 1/1 wall: Print time and date (rather than just time) in wall banner
Hello,
This is a simple change to print the date and time in the wall banner. Previously just the time was printed. This made more sense during the era of scarce and/or real terminals with interactive sessions of brief usage, when a terminal was likely to be attended, but makes less sense in the era of long-lived x-terminals, screen sessions, and so forth. The latter may be left open for days or weeks at a time, and returning to one it may no longer be obvious just when a wall message was sent. This can be relevant.
This adds the seconds and the date (locale-appropriate format) to the wall banner, if any.
Regards,
Dave Rutherford <[email protected]>
$ diff -u term-utils/wall.c.orig term-utils/wall.c
--- term-utils/wall.c.orig 2015-06-25 04:31:10.957160529 -0400
+++ term-utils/wall.c 2015-06-26 01:45:04.150729302 -0400
@@ -238,8 +238,9 @@
sprintf(lbuf, _("Broadcast Message from %s@%s"),
whom, hostname);
fprintf(fp, "%-79.79s\007\007\r\n", lbuf);
- sprintf(lbuf, " (%s) at %d:%02d ...",
- where, lt->tm_hour, lt->tm_min);
+ cnt = sprintf(lbuf, " (%s) at ", where);
+ mbuf = lbuf + cnt;
+ strftime(mbuf, 79-cnt, "%T %x ...", lt);
fprintf(fp, "%-79.79s\r\n", lbuf);
}
fprintf(fp, "%79s\r\n", " ");Quoted 20 lines · Dave Rutherford
This is a simple change to print the date and time in the wall banner. Previously just the time was printed. This made more sense during the era of scarce and/or real terminals with interactive sessions of brief usage, when a terminal was likely to be attended, but makes less sense in the era of long-lived x-terminals, screen sessions, and so forth. The latter may be left open for days or weeks at a time, and returning to one it may no longer be obvious just when a wall message was sent. This can be relevant.
This adds the seconds and the date (locale-appropriate format) to the wall banner, if any.
Regards,
Dave Rutherford <[email protected]>$ diff -u term-utils/wall.c.orig term-utils/wall.cwall.c 2015-06-26 01:45:04.150729302 -0400 renamed from wall.c.orig 2015-06-25 04:31:10.957160529 -0400 +0
-0@@ -238,8 +238,9 @@ sprintf(lbuf, _("Broadcast Message from %s@%s"),
wall.c 2015-06-26 01:45:04.150729302 -0400 line 246
Quoted 10 lines
wall.c 2015-06-26 01:45:04.150729302 -0400 renamed from wall.c.orig 2015-06-25 04:31:10.957160529 -0400 +3
-2whom, hostname); fprintf(fp, "%-79.79s\007\007\r\n", lbuf); - sprintf(lbuf, " (%s) at %d:%02d ...", - where, lt->tm_hour, lt->tm_min); + cnt = sprintf(lbuf, " (%s) at ", where); + mbuf = lbuf + cnt; + strftime(mbuf, 79-cnt, "%T %x ...", lt); fprintf(fp, "%-79.79s\r\n", lbuf); } fprintf(fp, "%79s\r\n", " ");
Hi Dave,
It seems your patch is wrote using rather old util-linux source. The code segment in question has got at least one change[1], that makes banner to be sysvinit compatible. Banner now uses a date string similar to date(1) default output, and it tends get truncated[2]. While back I thought splitting the banner to multiple lines might be good idea, but the wat I proposed the change did not satisfy review process[3].
Problem seems to be that the current header format simply does not have enough room for all the information, and no-one has come up with a good idea what would be better alternative format. Maybe the later has not been thought too much, and most certainly there has not been proposals for alternative(s).
That said now when everything is turning to json, maybe header and message should be json as well. Something like:
{
"title": "Broadcast message"
"from": "[email protected]"
"tty": "pts/2"
"date": "2015-06-27T09:18:36+0100"
"message": "the stuff users write"
}
[1] https://github.com/karelzak/util-linux/commit/d81c30553f4fb49173d38f69edff4b0b67a18b65
[2] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=682778
[3] http://marc.info/?l=util-linux-ng&m=140661986032132&w=2
Signature · 2 lines
Sami Kerola http://www.iki.fi/kerolasa/
Karel Zak
maintainerQuoted 2 lines · Sami Kerola
That said now when everything is turning to json, maybe header and message should be json as well. Something like:
For humans? Why?
Quoted 7 lines
{
"title": "Broadcast message"
"from": "[email protected]"
"tty": "pts/2"
"date": "2015-06-27T09:18:36+0100"
"message": "the stuff users write"
}
Anyway, I don't think the current output is so bad that we have to change it.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com