]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Attempt #2 to fix script(1) if the standard input is closed: If we
authorColin Percival <cperciva@FreeBSD.org>
Sun, 15 Feb 2004 17:30:13 +0000 (17:30 +0000)
committerColin Percival <cperciva@FreeBSD.org>
Sun, 15 Feb 2004 17:30:13 +0000 (17:30 +0000)
commitd6a68195afb81df3adb0eefffea083d219e8035e
tree4ce8c64fd19756fb195c1ad97da43d433878f6c0
parenta20e9655b95f468ced5400abf4797004abeaa593
Attempt #2 to fix script(1) if the standard input is closed: If we
read EOF from STDIN_FILENO, write zero bytes into the pseudo-terminal;
this is interpreted as an EOF by the program being scripted.

I've tested this with two non-interactive scripts:
# echo 5 | script foo sh -c 'read x; sleep $x; echo bar'
# echo bar | xargs script foo echo
and one interactive program:
# script foo more /etc/passwd
and everything seems to work properly...

PR: bin/56166, bin/57414, ports/57415, ports/60534
Approved by: rwatson (mentor)
MFC after: 2 weeks
usr.bin/script/script.c