Date: Sun, 17 Mar 2013 09:32:44 GMT From: Ivan Ivanyuk <ivan.ivanyuk@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: bin/177047: [patch] Adding date to wall(1) output message can be useful Message-ID: <201303170932.r2H9WiE4060134@red.freebsd.org> Resent-Message-ID: <201303170940.r2H9e08d068820@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 177047 >Category: bin >Synopsis: [patch] Adding date to wall(1) output message can be useful >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Mar 17 09:40:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Ivan Ivanyuk >Release: 8.3 >Organization: >Environment: FreeBSD planetes 8.3-RELEASE FreeBSD 8.3-RELEASE #1: Fri Aug 17 15:18:30 EEST 2012 root@planetes:/usr/obj/usr/src/sys/GW amd64 >Description: Currently wall output includes date in short format: HH:MM TZ It can be useful to have date included. Some utils use wall(1) for reporting events and it would be easier to see date of them at one glance. >How-To-Repeat: >Fix: Sample patch against 8.3 source attached. Very likely it has to be improved by real developer. Patch attached with submission follows: --- /usr/src/usr.bin/wall/wall.c 2012-03-03 08:15:13.000000000 +0200 +++ /home/zxadmin/wall/wall.c 2013-03-17 11:00:40.000000000 +0200 @@ -204,7 +204,7 @@ time_t now; FILE *fp; int fd; - char *p, hostname[MAXHOSTNAMELEN], lbuf[256], tmpname[64]; + char *p, hostname[MAXHOSTNAMELEN], lbuf[256], tmpname[64], datestr[20]; const char *tty; const char *whom; gid_t egid; @@ -224,6 +224,7 @@ (void)gethostname(hostname, sizeof(hostname)); (void)time(&now); lt = localtime(&now); + (void)strftime(datestr, sizeof datestr, "%b %d %H:%M %Z", lt); /* * all this stuff is to blank out a square for the message; @@ -238,8 +239,7 @@ whom, hostname); (void)fprintf(fp, "%-79.79s\007\007\r\n", lbuf); (void)snprintf(lbuf, sizeof(lbuf), - " (%s) at %d:%02d %s...", tty, - lt->tm_hour, lt->tm_min, lt->tm_zone); + " (%s) at %s...", tty, datestr); (void)fprintf(fp, "%-79.79s\r\n", lbuf); } (void)fprintf(fp, "%79s\r\n", " "); >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303170932.r2H9WiE4060134>