Coder Social home page Coder Social logo

Comments (3)

karelzak avatar karelzak commented on June 9, 2024

I cannot reproduce this problem. script --quiet or script --quiet anyfile works for me.

What version of the script do you have? And can you provide any example?

from util-linux.

resolritter avatar resolritter commented on June 9, 2024

@karelzak

I cannot reproduce this problem. script --quiet or script --quiet anyfile works for me.

What version of the script do you have?

The version of script I was using is 2.39.3.

And can you provide any example?

Since this ticket is about logging, you can try it it --log-in or --log-out. For example, script --quiet --log-out /path/to/file. You'll notice that the "Script started on ..." message is always appended at the start of the log regardless of --quiet. There's not really any special step in order to reproduce this, other than using the logging options and observing the log.

I've applied a patch locally which dealt with the problem. I no longer see the "Script started on ..." message appear in the logs after that. The basic idea is to wrap the logging in log_start with an if statement, like so:

diff --git a/term-utils/script.c b/term-utils/script.c
index 3457ac8..9cce9b4 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -391,30 +391,32 @@ static int log_start(struct script_control *ctl,
 	switch (log->format) {
 	case SCRIPT_FMT_RAW:
 	{
-		int x = 0;
-		char buf[FORMAT_TIMESTAMP_MAX];
-		time_t tvec = script_time((time_t *)NULL);
+		if (!ctl->quiet) {
+			int x = 0;
+			char buf[FORMAT_TIMESTAMP_MAX];
+			time_t tvec = script_time((time_t *)NULL);
 
-		strtime_iso(&tvec, ISO_TIMESTAMP, buf, sizeof(buf));
-		fprintf(log->fp, _("Script started on %s ["), buf);
+			strtime_iso(&tvec, ISO_TIMESTAMP, buf, sizeof(buf));
+			fprintf(log->fp, _("Script started on %s ["), buf);
 
-		if (ctl->command)
-			x += fprintf(log->fp, "COMMAND=\"%s\"", ctl->command_norm);
+			if (ctl->command)
+				x += fprintf(log->fp, "COMMAND=\"%s\"", ctl->command_norm);
 
-		if (ctl->isterm) {
-			init_terminal_info(ctl);
+			if (ctl->isterm) {
+				init_terminal_info(ctl);
 
-			if (ctl->ttytype)
-				x += fprintf(log->fp, "%*sTERM=\"%s\"", !!x, "", ctl->ttytype);
-			if (ctl->ttyname)
-				x += fprintf(log->fp, "%*sTTY=\"%s\"", !!x, "", ctl->ttyname);
+				if (ctl->ttytype)
+					x += fprintf(log->fp, "%*sTERM=\"%s\"", !!x, "", ctl->ttytype);
+				if (ctl->ttyname)
+					x += fprintf(log->fp, "%*sTTY=\"%s\"", !!x, "", ctl->ttyname);
 
-			x += fprintf(log->fp, "%*sCOLUMNS=\"%d\" LINES=\"%d\"", !!x, "",
-					ctl->ttycols, ctl->ttylines);
-		} else
-			fprintf(log->fp, _("%*s<not executed on terminal>"), !!x, "");
+				x += fprintf(log->fp, "%*sCOLUMNS=\"%d\" LINES=\"%d\"", !!x, "",
+						ctl->ttycols, ctl->ttylines);
+			} else
+				fprintf(log->fp, _("%*s<not executed on terminal>"), !!x, "");
 
-		fputs("]\n", log->fp);
+			fputs("]\n", log->fp);
+		}
 		break;
 	}
 	case SCRIPT_FMT_TIMING_SIMPLE:

I can submit a PR for the patch if it looks acceptable.

from util-linux.

karelzak avatar karelzak commented on June 9, 2024

But it's not expected that --quite suppress anything in the log, man script:

      -q, --quiet
           Be quiet (do not write start and done messages to standard output).

from util-linux.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.