From owner-svn-src-all@FreeBSD.ORG Thu Sep 16 22:31:04 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 03EB21065670; Thu, 16 Sep 2010 22:31:04 +0000 (UTC) (envelope-from obrien@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id E77A18FC18; Thu, 16 Sep 2010 22:31:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o8GMV3wO009121; Thu, 16 Sep 2010 22:31:03 GMT (envelope-from obrien@svn.freebsd.org) Received: (from obrien@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8GMV3Ov009118; Thu, 16 Sep 2010 22:31:03 GMT (envelope-from obrien@svn.freebsd.org) Message-Id: <201009162231.o8GMV3Ov009118@svn.freebsd.org> From: "David E. O'Brien" Date: Thu, 16 Sep 2010 22:31:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r212770 - head/usr.bin/script X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Sep 2010 22:31:04 -0000 Author: obrien Date: Thu Sep 16 22:31:03 2010 New Revision: 212770 URL: http://svn.freebsd.org/changeset/base/212770 Log: + Add the SCRIPT environmental variable to the sub-shell. Its value is the name of the typescript file. + 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. Modified: head/usr.bin/script/script.1 head/usr.bin/script/script.c Modified: head/usr.bin/script/script.1 ============================================================================== --- head/usr.bin/script/script.1 Thu Sep 16 22:11:55 2010 (r212769) +++ head/usr.bin/script/script.1 Thu Sep 16 22:31:03 2010 (r212770) @@ -117,6 +117,19 @@ The results are meant to emulate a hardc The following environment variable is utilized by .Nm : .Bl -tag -width SHELL +.It Ev SCRIPT +The +.Ev SCRIPT +environment variable is added to the sub-shell. +If +.Ev SCRIPT +already existed in the users environment, +its value is overwritten within the sub-shell. +The value of +.Ev SCRIPT +is the name of the +.Ar typescript +file. .It Ev SHELL If the variable .Ev SHELL Modified: head/usr.bin/script/script.c ============================================================================== --- head/usr.bin/script/script.c Thu Sep 16 22:11:55 2010 (r212769) +++ head/usr.bin/script/script.c Thu Sep 16 22:31:03 2010 (r212770) @@ -235,14 +235,21 @@ static void 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); + setenv("SCRIPT", fname, 1); if (av[0]) { execvp(av[0], av); warn("%s", av[0]);