X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/3b600ead559fe112c8ab5ec49de92ae74ae4a1c9..31cef89cb428866f787983e68246030321893df4:/usr/src/cmd/write.c?ds=inline diff --git a/usr/src/cmd/write.c b/usr/src/cmd/write.c index b896a7c15c..626a98f8f7 100644 --- a/usr/src/cmd/write.c +++ b/usr/src/cmd/write.c @@ -1,3 +1,4 @@ +static char *sccsid = "@(#)write.c 4.2 (Berkeley) 11/10/80"; /* * write to another user */ @@ -7,6 +8,10 @@ #include #include #include +#include + +#define NMAX sizeof(ubuf.ut_name) +#define LMAX sizeof(ubuf.ut_line) char *strcat(); char *strcpy(); @@ -23,6 +28,7 @@ int logcnt; int eof(); int timout(); FILE *tf; +char *getenv(); main(argc, argv) char *argv[]; @@ -31,6 +37,9 @@ char *argv[]; register i; register FILE *uf; int c1, c2; + long clock = time( 0 ); + struct tm *localtime(); + struct tm *localclock = localtime( &clock ); if(argc < 2) { printf("usage: write user [ttyname]\n"); @@ -54,8 +63,10 @@ char *argv[]; strcat(histty, histtya); } while (fread((char *)&ubuf, sizeof(ubuf), 1, uf) == 1) { + if (ubuf.ut_name[0] == '\0') + continue; if (strcmp(ubuf.ut_line, mytty)==0) { - for(i=0; i<8; i++) { + for(i=0; i tm_hour , localclock -> tm_min ); fflush(tf); for(;;) { char buf[128]; @@ -129,6 +141,8 @@ cont: continue; } write(fileno(tf), buf, i); + if ( buf[ i - 1 ] == '\n' ) + write( fileno( tf ) , "\r" , 1 ); } perm: @@ -139,14 +153,14 @@ perm: timout() { - printf("Timeout opening his tty\n"); + printf("Timeout opening their tty\n"); exit(1); } eof() { - fprintf(tf, "EOF\n"); + fprintf(tf, "EOF\r\n"); exit(0); } @@ -163,7 +177,7 @@ char *bp; } if(i == 0) { sigs((int (*)())0); - execl("/bin/sh", "sh", "-c", bp+1, 0); + execl(getenv("SHELL") ? getenv("SHELL") : "/bin/sh", "sh", "-c", bp+1, 0); exit(0); } while(wait((int *)NULL) != i)