Commit graph

107 commits

Author SHA1 Message Date
Kyle Evans 8ceac8e13d script: handle terminal resize on SIGWINCH
Add a -w flag to forward terminal resize events on to the child, which
can be useful in some circumstances to avoid terminal corruption.

Reviewed by:	des
Co-authored-by:	Xavier Beaudouin <xavier.beaudouin@klarasystems.com>
Sponsored by:	Modirum MDPay
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D44167
2024-04-26 11:39:00 -05:00
Xavier Beaudouin 4459abe334 script: minor style improvements
Fix some nits pointed out by checkstyle9.pl in advance of functional
changes to script(1).

Reviewed by:	des
Sponsored by:	Modirum MDPay
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D44167
2024-04-26 11:38:52 -05:00
Warner Losh 0b8224d1cc Remove copyright strings ifdef'd out
We've ifdef'd out the copyright strings for some time now. Go ahead and
remove the ifdefs. Plus whatever other detritis was left over from other
recent removals. These copyright strings are present in the comments and
are largely from CSRG's attempt at adding their copyright to every
binary file (which modern interpretations of the license doesn't
require).

Sponsored by:		Netflix
2023-11-26 22:23:58 -07:00
Warner Losh bdcbfde31e usr.bin: Remove ancient SCCS tags.
Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by:		Netflix
2023-11-26 22:23:30 -07:00
Warner Losh b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Alfonso Gregory cccdaf507e Mark usage function as __dead2 in programs where it does not return
In most cases, usage does not return, so mark them as __dead2. For the
cases where they do return, they have not been marked __dead2.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/735
2023-07-07 10:45:18 -06:00
Simon J. Gerraty d9a4274795 Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Dag-Erling Smørgrav 473e9fcab4 script: Handle a missing 's' stamp gracefully.
Sponsored by:	Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D37182
2022-10-27 20:11:36 +00:00
Dag-Erling Smørgrav 6ac087cf8f script: Further usage string nits.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D37177
2022-10-27 19:49:18 +00:00
Dag-Erling Smørgrav 3276866f40 script: Use size_t / ssize_t where needed.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D37177
2022-10-27 19:49:18 +00:00
Dag-Erling Smørgrav e7c13cf438 script: Add usage string for playback mode.
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D37138
2022-10-27 14:46:15 +00:00
Dag-Erling Smørgrav 8e096e24d4 script: Correct -F in man page and usage string.
Sponsored by:	Klara, Inc.
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D37138
2022-10-27 14:46:09 +00:00
Simon J. Gerraty 31fde97357 script: use %n at the end of default tstamp_fmt
Since we are only outputting time-stamps when they differ
ending it with a newline, interferes with the output less.
2022-03-10 09:42:55 -08:00
Simon J. Gerraty 7b45ad3f89 script -T skip timstamps for same second
The result is much more readable if we only output the time-stamp
when it is at least 1s since last one.
2022-03-09 22:19:53 -08:00
Simon J. Gerraty 6c4afed566 script add -T fmt to print time-stamps
script -r is useful for recording time-stamps of when output
happened.  With -T, rather than playback the script in real-time
we simply print the time-stamps to show when the output happened.

This is very useful for example, for analyzing boot time activity.

If the fmt provided contains no % characters the default
%n@ %s [%Y-%m-%d %T]
is used, which lends itself to analysis by tools as well as humans.

Sponsored by:	Juniper Networks, Inc.

Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D34511
2022-03-09 13:33:03 -08:00
Konstantin Belousov c0ba4c2ee2 script(1): work around slow reading child
If child is slow reading from its input, or even completely stops doing
the read, script(1) hangs in write(2) to the pts master waiting until
there is a space in the terminal discipline buffer.  This also stops
handling any outer io, as well as child output.

Work around the problem by making pts master fd non-blocking, and be
prepared for short writes to it.  The data to be written to master is
buffered in the tailq which is processed when select(2) detects that
master is ready for write.

PR:	260938
Reported by:	наб <nabijaczleweli@nabijaczleweli.xyz>
See also:	https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1003095
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D33789
2022-01-10 17:34:51 +02:00
Mateusz Piotrowski d41149a8e9 Add some examples to script.1
While here:

- Split synopsis into two parts. The first explains how to record
  sessions, while the second one explains how to replay (some of)
  the recorded sessions.
- Fix the -width argument of the environment variables list.

MFC after:	1 week
2021-01-05 16:32:27 +01:00
Mateusz Piotrowski 225afb6cad Improve readability of the options list
MFC after:	3 days
2021-01-05 15:46:56 +01:00
Warner Losh 84961358b4 Fix typo in comment.
Noticed by: bapt@
2020-09-05 04:20:29 +00:00
Warner Losh 44a3c7a3f8 Bump date for r365052 2020-09-01 16:13:09 +00:00
Warner Losh f9177b6c91 Have script accept and ignore -e for Linux compat
In the util-linux version of script, it will always exit with succes.
Except when run with -e, in which case it will have the exit value of
the child. BSD Script already uses the child's exit value for its exit
value. Some config and other helper scripts depend on being able to
specify -e. Accept it for compatibility since we'll already to the
right thing, but otherwise we ignore it.
2020-09-01 16:11:23 +00:00
Mark Johnston 8bc30d2afd script: Minor cleanups.
- Instead of using isatty() to decide whether to call tcgetattr(), just
  call tcgetattr() directly, since that's all that isatty() does anyway.
- Simplify error handling in termset().  Check for errno != ENOTTY from
  tcgetattr() to handle errors that may be raised while running
  script(1) under a debugger.

PR:		248377
Submitted by:	Soumendra Ganguly <soumendraganguly@gmail.com>
MFC after:	1 week
2020-08-11 14:19:05 +00:00
Mark Johnston 69bc4fa916 script: Put the terminal in raw mode when playing back a session.
Otherwise recorded sessions of some interactive programs do not play
back properly.

PR:		248377
Submitted by:	Soumendra Ganguly <0.gangzta@gmail.com>
MFC after:	1 week
2020-08-07 18:48:56 +00:00
Pedro F. Giffuni 8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Bryan Drewery ea825d0274 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	Dell EMC Isilon
2017-10-31 00:07:04 +00:00
Warner Losh fbbd9655e5 Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2017-02-28 23:42:47 +00:00
Baptiste Daroussin 26e736b2c0 Directly set the O_CLOEXEC flags via the open(2) attributes
MFC after:	1 week
2016-04-16 12:47:23 +00:00
Bryan Drewery 66d93438b1 Record command exit status in the typescript file when running simple commands.
Also capitalize 'command:'.

Relnotes:	yes
MFC after:	2 weeks
Sponsored by:	EMC / Isilon Storage Division
2016-03-08 18:05:23 +00:00
Bryan Drewery 95d13d1b02 Just exit in the child if execve(2) fails.
No functional change.

This is mostly addressing a false-positive from the clang static
analyzer due to it thinking that done() was being called with freed
memory, however the kill(0, SIGTERM) made the done() never reached.
It doesn't make sense to the show the footer from the child anyhow, nor
does it make sense to kill the process group here since the execve(2)
failed in the child.  This code was leftover from many years of refactoring.

MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2016-03-08 18:05:20 +00:00
Bryan Drewery 7b245cb846 Filemon: Attach from the child to avoid racing with the parent attach.
This is the same as how the bmake filemon usage works.

This also fixes failed attach not properly flushing the TTY.

MFC after:	1 week
Relnotes:	yes
Sponsored by:	EMC / Isilon Storage Division
2016-03-08 18:05:02 +00:00
Sergey Kandaurov d7deff23cd Fix SEE ALSO.
The history mechanism applies to csh.

Sponsored by:	Nginx, Inc.
2015-08-26 11:54:40 +00:00
Simon J. Gerraty ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty 44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty 98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Joel Dahl 914f6e6290 mdoc: sort SEE ALSO. 2014-12-26 21:56:23 +00:00
Baptiste Daroussin 3e11bd9e2a Convert to usr.bin/ to LIBADD
Reduce overlinking
2014-11-25 14:29:10 +00:00
Simon J. Gerraty fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty 76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty 3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Mikolaj Golub 29f4384a31 Bring back r226403, the fix for bin/161526, which was (accidentally?)
reverted in r238896.

PR:		bin/161526
Reported by:	Karli.Sjoberg slu.se
MFC after:	3 days
2014-01-17 21:45:25 +00:00
Tom Rhodes 8d105abc4f Add -F to flush output after each write. With this, I can
set up a pipe and allow a jr user to watch what I'm doing
by running 'script -F pipefile' on it.

While here, spell out the month in the .Dd tag like other
manual pages.
2013-12-05 01:44:24 +00:00
Simon J. Gerraty d1d0158641 Merge from head 2013-09-05 20:18:59 +00:00
David E. O'Brien c89bc70064 MFC'ing to 9.2. 2013-07-30 19:21:36 +00:00
Simon J. Gerraty 69e6d7b75e sync from head 2013-04-12 20:48:55 +00:00
Sergey Kandaurov 99f23359a5 Fix version in the .Fx macro.
Reported by:	<deeptech71@gmail.com>
2013-03-16 22:37:56 +00:00
Simon J. Gerraty 7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Simon J. Gerraty f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
Simon J. Gerraty 23090366f7 Sync from head 2012-11-04 02:52:03 +00:00