Commit Graph

37 Commits

Author SHA1 Message Date
Colin Percival
d6a68195af 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
2004-02-15 17:30:13 +00:00
Colin Percival
0a43b788bf Back out part of 1.21, since it breaks script interactive-program. This
re-breaks non-interactive portupgrade (or at least old versions of
portupgrade); I'll see if I can put together a solution which avoids
breaking anything later.

Approved by:	rwatson (mentor)
Noticed by:	Stefan Farfeleder, Joshua Goodall
2004-01-27 17:50:47 +00:00
Sheldon Hearn
4294ff16a7 Fix SYNOPSIS of manual page, clustering no-arg options correctly.
Sync usage with manpage.
2004-01-22 21:26:41 +00:00
Colin Percival
e292a0e3f1 Two fixes for script(1):
1. Don't do tty stuff to stdin if stdin isn't a tty.
2. When running in non-interactive mode, don't select(2)
on the standard input.

This un-breaks non-interactive portupgrade.

PR: bin/59036 [1]
PR: bin/56166, bin/57414, ports/57415, ports/60534 [2]
MFC after: 7 days
Approved by: rwatson (mentor)
2004-01-22 21:01:14 +00:00
Philippe Charnier
fed771de60 Introduce arguments the standard way. In .Ar command ..., ... is not an
argument, command is.
2003-09-07 15:43:50 +00:00
David Malone
f4ac32def2 ANSIify function definitions.
Add some constness to avoid some warnings.
Remove use register keyword.
Deal with missing/unneeded extern/prototypes.
Some minor type changes/casts to avoid warnings.

Reviewed by:	md5
2002-09-04 23:29:10 +00:00
Mike Barcroft
cb263c3594 Use POSIX macros for wait(2)-style status information instead of the
deprecated 4.2/4.3BSD wait union.  Fix some nearby pid_t/int
confusion.
2002-06-03 23:13:11 +00:00
Philippe Charnier
e8937ba009 Use `The .Nm utility' 2002-04-20 12:18:28 +00:00
Warner Losh
3f330d7d1a remove __P 2002-03-22 01:42:45 +00:00
Mark Murray
d20f95e121 Minor style stuff, use __FBSDID(), remove to-be-default WARNS=2. 2001-12-12 23:23:52 +00:00
David Malone
9f5b04e925 Style improvements recommended by Bruce as a follow up to some
of the recent WARNS commits. The idea is:

1) FreeBSD id tags should follow vendor tags.
2) Vendor tags should not be compiled (though copyrights probably should).
3) There should be no blank line between including cdefs and __FBSDIF.
2001-12-10 21:13:08 +00:00
David Malone
b139689c6b Warns cleanups. Add FreeBSD ID. 2001-12-03 21:22:56 +00:00
Sheldon Hearn
e1b4d8d074 Use STD{ERR,IN,OUT}_FILENO instead of their numeric values. The
definitions are more readable, and it's possible that they're
more portable to pathalogical platforms.

Submitted by:   David Hill <david@phobia.ms>
2001-07-26 11:02:39 +00:00
Dima Dorfman
f247324df7 Remove whitespace at EOL. 2001-07-15 08:06:20 +00:00
Ruslan Ermilov
625003720a mdoc(7) police: removed HISTORY info from the .Os call. 2001-07-10 14:16:33 +00:00
Brian Somers
7bc6d0158f Fix the type of the NULL arg to execl()
Idea from: Theo de Raadt <deraadt@openbsd.org>
2001-07-09 09:24:06 +00:00
Dima Dorfman
7309915e7a Nuke unused variables. 2001-06-24 23:41:57 +00:00
Ruslan Ermilov
8fe908ef0c mdoc(7) police: use the new features of the Nm macro. 2000-11-20 19:21:22 +00:00
Kris Kennaway
b7ffba17f8 Don't call warn() with no format string. 2000-07-10 09:18:19 +00:00
Brian Feldman
2cb6b4ef51 Make a run-on sentence into two proper sentences, and clarify the meaning
a bit.
2000-03-06 23:06:11 +00:00
Sheldon Hearn
4e86fcacf6 Remove more single-space hard sentence breaks. 2000-03-02 14:54:02 +00:00
Sheldon Hearn
87faa07bec Remove single-space hard sentence breaks. These degrade the quality
of the typeset output, tend to make diffs harder to read and provide
bad examples for new-comers to mdoc.
2000-03-01 12:20:22 +00:00
Bill Fumerola
128a149b6a Fix grammar error. (missing verb) 1999-12-13 23:37:56 +00:00
Guido van Rooij
725585340b Adjust man page: if command is specified, file name is mandatory 1999-11-24 15:47:45 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Sheldon Hearn
5cba8ccae5 Pass as argv[0] the name of the shell executed instead of "sh".
PR:	2851
Reported by:	era@iki.fi
Obtained from:	NetBSD
1999-08-11 23:45:59 +00:00
Joseph Koshy
4cbaceabf1 Mention default time between output flushes in manual page.
PR:		docs/8009
Submitted by:	Stefan Eggers <seggers@semyam.dinoco.de>
1998-09-29 01:49:49 +00:00
Dag-Erling Smørgrav
b1c669700c Fix the following bugs:
- if a command was specified and script(1) failed to execute it,
    it would print the name of your shell in the error message
    instead of that of the command that failed.

  - since finish() was installed as a SIGCHLD handler, it would
    often run before the main loop had had time to process the
    last few bytes of output. This resulted in very strange
    truncated error messages.

  - script(1) would almost always return with an exit status of 0,
    even if the command returned a non-zero exit status. This broke
    my 'build world, install it and rebuild the kernel' scripts
    because 'make installworld' would run even if 'make buildworld'
    had failed.
1998-09-19 09:45:42 +00:00
Steve Price
32c2131395 Fix a bunch of spelling errors.
PR:		6856
Submitted by:	Josh Gilliam <josh@quick.net>
1998-06-04 21:06:07 +00:00
Peter Wemm
e8eb82a81c Rewrite script as a select loop rather than as a twin reader/write process.
This allows simple logging of keys sent to a session (turned on with -k).
Also allow specifying the script file flush interval.
1998-03-08 14:19:18 +00:00
Peter Wemm
0e604e984a Fix typo while copying patch from the 2.2 system that it came from
Use execvp rather than execv so that full paths are not needed.
1997-12-30 01:20:08 +00:00
Peter Wemm
51afb8df2c script(1) has annoyed me with it's inflexable command argument parsing
since I first saw it.  I finally needed to pass arguments through to
the spawned command badly enough (and urgently) that I threw this together.
1997-12-29 13:31:46 +00:00
Philippe Charnier
236d2f5583 Add usage(). Use err(3) instead of local redefinition. 1997-08-08 12:24:49 +00:00
Warner Losh
1c8af87873 compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-29 04:34:07 +00:00
Bruce Evans
eaa86f9d7f Don't use __dead or __pure in user code. They were obfuscations
for gcc >= 2.5 and no-ops for gcc >= 2.6.  Converted to use __dead2
or __pure2 where it wasn't already done, except in math.h where use
of __pure was mostly wrong.
1996-09-14 03:00:32 +00:00
Garrett Wollman
656dcd4316 Delete bogus referneces to timezone code internal header file `tzfile.h',
which is no longer bogusly installed in /usr/include.
1995-08-07 19:17:46 +00:00
Rodney W. Grimes
9b50d90275 BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00