svn commit: r212770 - head/usr.bin/script

Anonymous swell.k at gmail.com
Mon Dec 20 08:34:55 UTC 2010


Anonymous <swell.k at gmail.com> writes:

> "David E. O'Brien" <obrien at FreeBSD.org> writes:
>
>> Author: obrien
>> Date: Thu Sep 16 22:31:03 2010
>> New Revision: 212770
>> URL: http://svn.freebsd.org/changeset/base/212770
>>
>> Log:
>>   + Add the 'command' argument (if supplied on the command line) to the
>>   typescript file.  This creates a more complete typescript when invoked
>>   this way - more equal to invoking script without supplying the 'command'
>>   argument.
> [...]
>> +	if (av[0])
>> +		for (k = 0 ; av[k] ; ++k)
>> +			fprintf(fscript, "%s%s", k ? " " : "", av[k]);
>> +		fprintf(fscript, "\r\n");
>> +
>
> Can you make it opt-in? It breaks scripts that do not expect anything
> other than command output in a typescript. For example, timestamps can
> be disabled by `-q' option.

So, how about putting it under `-q' and making it more easy to notice.

%%
Index: usr.bin/script/script.1
===================================================================
--- usr.bin/script/script.1	(revision 216581)
+++ usr.bin/script/script.1	(working copy)
@@ -75,7 +75,7 @@
 .It Fl k
 Log keys sent to program as well as output.
 .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 t Ar time
 Specify time interval between flushing script output file.
 A value of 0
Index: usr.bin/script/script.c
===================================================================
--- usr.bin/script/script.c	(revision 216581)
+++ usr.bin/script/script.c	(working copy)
@@ -86,6 +86,7 @@
 	char ibuf[BUFSIZ];
 	fd_set rfd;
 	int flushtime = 30;
+	int k;
 
 	aflg = kflg = 0;
 	while ((ch = getopt(argc, argv, "aqkt:")) != -1)
@@ -137,6 +138,11 @@
 		tvec = time(NULL);
 		(void)printf("Script started, output file is %s\n", fname);
 		(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) {
@@ -231,17 +237,11 @@
 doshell(char **av)
 {
 	const char *shell;
-	int k;
 
 	shell = getenv("SHELL");
 	if (shell == NULL)
 		shell = _PATH_BSHELL;
 
-	if (av[0])
-		for (k = 0 ; av[k] ; ++k)
-			fprintf(fscript, "%s%s", k ? " " : "", av[k]);
-		fprintf(fscript, "\r\n");
-
 	(void)close(master);
 	(void)fclose(fscript);
 	login_tty(slave);
%%


More information about the svn-src-all mailing list