* [PATCH 0/3] script: no logging for non-interactive shells
@ 2015-02-10 21:30 Stanislav Brabec
2015-02-11 10:05 ` Karel Zak
0 siblings, 1 reply; 4+ messages in thread
From: Stanislav Brabec @ 2015-02-10 21:30 UTC (permalink / raw)
To: util-linux
Many people use script in their shell initialization files. It has some
unwanted consequences, e. g. logging commands from cron (and starting
them in a pseudo-terminal and interactive shell). It could also result
in a seemingly hanging applications:
For example:
echo -e './script\nTERM=linux mutt' | \
at $(date -d "+1 minute 5 seconds" +%H:%M)
mutt will "hang" inside at, because it thinks that it is running in an
interactive shell and waits for input.
That is why I wrote --interactive command line option. If it is set,
script called from a non-interactive session will not log anything, just
(optionally) execute -c argument and silently exit.
Note that similar behavior existed between f50473e and 3822032, but the
new proposed behavior does not generate error.
--
Best Regards / S pozdravem,
Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o. e-mail: sbrabec@suse.cz
Lihovarská 1060/12 tel: +49 911 7405384547
190 00 Praha 9 fax: +420 284 084 001
Czech Republic http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 0/3] script: no logging for non-interactive shells
2015-02-10 21:30 [PATCH 0/3] script: no logging for non-interactive shells Stanislav Brabec
@ 2015-02-11 10:05 ` Karel Zak
2015-02-11 14:07 ` Stanislav Brabec
0 siblings, 1 reply; 4+ messages in thread
From: Karel Zak @ 2015-02-11 10:05 UTC (permalink / raw)
To: Stanislav Brabec; +Cc: util-linux
On Tue, Feb 10, 2015 at 10:30:35PM +0100, Stanislav Brabec wrote:
> Many people use script in their shell initialization files. It has some
> unwanted consequences, e. g. logging commands from cron (and starting them
> in a pseudo-terminal and interactive shell). It could also result in a
> seemingly hanging applications:
>
> For example:
>
> echo -e './script\nTERM=linux mutt' | \
> at $(date -d "+1 minute 5 seconds" +%H:%M)
>
> mutt will "hang" inside at, because it thinks that it is running in an
> interactive shell and waits for input.
>
> That is why I wrote --interactive command line option. If it is set, script
> called from a non-interactive session will not log anything, just
> (optionally) execute -c argument and silently exit.
Would be better to learn people to fix their shell initialization
files to not call script(1) for non-interactive sessions?
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 0/3] script: no logging for non-interactive shells
2015-02-11 10:05 ` Karel Zak
@ 2015-02-11 14:07 ` Stanislav Brabec
2015-02-12 13:31 ` Karel Zak
0 siblings, 1 reply; 4+ messages in thread
From: Stanislav Brabec @ 2015-02-11 14:07 UTC (permalink / raw)
To: Karel Zak; +Cc: util-linux
Karel Zak wrote:
> Would be better to learn people to fix their shell initialization
> files to not call script(1) for non-interactive sessions?
It makes sense.
>From 8fff32e65399ae07f70e12568d4d5278725673a7 Mon Sep 17 00:00:00 2001
From: Stanislav Brabec <sbrabec@suse.cz>
Date: Wed, 11 Feb 2015 15:02:10 +0100
Subject: [PATCH] script.1: Document behavior in non-interactive shells
And discourage users from such use.
---
term-utils/script.1 | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/term-utils/script.1 b/term-utils/script.1
index 4573f07..f32030c 100644
--- a/term-utils/script.1
+++ b/term-utils/script.1
@@ -121,6 +121,26 @@ create garbage in the typescript file.
.B script
works best with commands that do not manipulate the screen, the results are
meant to emulate a hardcopy terminal.
+.PP
+It is not recommended to run
+.B script
+in non-interactive shells. The inner shell of
+.B script
+is always interactive, and this could lead to unexpected results. If you use
+.B script
+in the shell initialization file (profile), you should use e. g.
+.RS
+.RE
+.sp
+.na
+.RS
+.nf
+if test -t 0 ; then
+ script
+fi
+.fi
+.RE
+.PP
.SH ENVIRONMENT
The following environment variable is utilized by
.BR script :
--
2.2.2
--
Best Regards / S pozdravem,
Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o. e-mail: sbrabec@suse.cz
Lihovarská 1060/12 tel: +49 911 7405384547
190 00 Praha 9 fax: +420 284 084 001
Czech Republic http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/3] script: no logging for non-interactive shells
2015-02-11 14:07 ` Stanislav Brabec
@ 2015-02-12 13:31 ` Karel Zak
0 siblings, 0 replies; 4+ messages in thread
From: Karel Zak @ 2015-02-12 13:31 UTC (permalink / raw)
To: Stanislav Brabec; +Cc: util-linux
On Wed, Feb 11, 2015 at 03:07:52PM +0100, Stanislav Brabec wrote:
> Subject: [PATCH] script.1: Document behavior in non-interactive shells
Applied, thanks :-)
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-02-12 13:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-10 21:30 [PATCH 0/3] script: no logging for non-interactive shells Stanislav Brabec
2015-02-11 10:05 ` Karel Zak
2015-02-11 14:07 ` Stanislav Brabec
2015-02-12 13:31 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox