bin/114465: [patch] [request] script(1): add really cool -d,
-p & -r options from NetBSD
Anonymous
swell.k at gmail.com
Mon Dec 20 15:20:12 UTC 2010
The following reply was made to PR bin/114465; it has been noted by GNATS.
From: Anonymous <swell.k at gmail.com>
To: Ighighi <ighighi at gmail.com>
Cc: bug-followup at FreeBSD.org
Subject: Re: bin/114465: [patch] [request] script(1): add really cool -d, -p & -r options from NetBSD
Date: Mon, 20 Dec 2010 18:11:37 +0300
Anonymous <swell.k at gmail.com> writes:
> Here's a regen'd diff against script.c at r1.17 with the *argv[] spamming
> change commented out atm.
And here's a fix that works with r212770.
--- script_replay.1.diff begins here ---
--- usr.bin/script/script.1~
+++ usr.bin/script/script.1
@@ -79,7 +79,7 @@ Log keys sent to program as well as outp
.It Fl p
Play back a recorded session in real time.
.It Fl q
-Run in quiet mode, omit the start and stop status messages.
+Run in quiet mode, omit the start, stop and command status messages.
.It Fl r
Record a session with input, output, and timestamping.
.It Fl t Ar time
--- usr.bin/script/script.c~
+++ usr.bin/script/script.c
@@ -64,7 +64,7 @@ static const char sccsid[] = "@(#)script
#define DEF_BUF 65536
-static struct stamp {
+struct stamp {
uint64_t scr_len; /* amount of data */
uint64_t scr_sec; /* time it arrived in seconds... */
uint32_t scr_usec; /* ...and microseconds */
@@ -102,6 +102,7 @@ main(int argc, char *argv[])
char ibuf[BUFSIZ];
fd_set rfd;
int flushtime = 30;
+ int k;
aflg = kflg = pflg = 0;
usesleep = 1;
@@ -170,8 +171,14 @@ main(int argc, char *argv[])
if (!qflg) {
tvec = time(NULL);
(void)printf("Script started, output file is %s\n", fname);
- if (!rawout)
+ if (!rawout) {
(void)fprintf(fscript, "Script started on %s", ctime(&tvec));
+ if (argv[0])
+ fprintf(fscript, "command: ");
+ for (k = 0 ; argv[k] ; ++k)
+ fprintf(fscript, "%s%s", k ? " " : "", argv[k]);
+ fprintf(fscript, "\n");
+ }
fflush(fscript);
}
if (ttyflg) {
@@ -271,19 +278,11 @@ static void
doshell(char **av)
{
const char *shell;
- int k;
shell = getenv("SHELL");
if (shell == NULL)
shell = _PATH_BSHELL;
-#if 0
- if (av[0])
- for (k = 0 ; av[k] ; ++k)
- fprintf(fscript, "%s%s", k ? " " : "", av[k]);
- fprintf(fscript, "\r\n");
-#endif
-
(void)close(master);
(void)fclose(fscript);
login_tty(slave);
@@ -346,7 +345,7 @@ record(FILE *fp, char *buf, size_t cc, i
err(1, "writev");
}
-void
+static void
consume(FILE *fp, off_t len, char *buf, int reg)
{
size_t l;
@@ -412,11 +411,13 @@ playback(FILE *fp)
switch (stamp.scr_direction) {
case 's':
+ if (!qflg)
(void)printf("Script started on %s", ctime(&tclock));
tsi = tso;
(void)consume(fp, stamp.scr_len, buf, reg);
break;
case 'e':
+ if (!qflg)
(void)printf("\nScript done on %s", ctime(&tclock));
(void)consume(fp, stamp.scr_len, buf, reg);
break;
--- script_replay.1.diff ends here ---
More information about the freebsd-bugs
mailing list