Skip to contentSkip to conversation

script.1: Improve documentation of non-interactive behavior

PATCH New Stanislav Brabec 1 participant 1 message Feb 13, 2015 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 script.1: Improve documentation of non-interactive behavior

- use exit in .profile to avoid non-logged session after typing "exit"
- document that script can read more from stdin than the command inside:

echo -e 'script -c "read a b ; echo a=\$a b=\$b >defs.sh"\n1 2\necho Done' | sh Script started, file is typescript
1 2
echo Done
Script done, file is typescript

---
 term-utils/script.1 | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
term-utils/script.1 +7 -1
index e130c77..6b566fe 100644
@@ -128,7 +128,8 @@ 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.
+in the shell initialization file, you have to avoid entering an infinite
+loop. Use e. g. profile file, which is read by login shells only:
 .RS
 .RE
 .sp
@@ -137,10 +138,15 @@ in the shell initialization file (profile), you should use e. g.
 .nf
 if test -t 0 ; then
     script
+    exit
 fi
 .fi
 .RE
 .PP
+You should also avoid use of script in command pipes, as
+.B script
+can read more input than you would expect.
+.PP
 .SH ENVIRONMENT
 The following environment variable is utilized by
 .BR script :
Signature · 13 lines
2.2.2

-- 
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                          e-mail: [email protected]
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