From: Greg Troxel <
g...@lexort.com>
- Document script(1) invocations on various systems.
- Change script(1) arg order to accomodate a greater variety of
systems.
- On NetBSD, sleep after script(1) invocation because it returns
before the commands have finished, when stdin is /dev/null.
Signed-off-by: Greg Troxel <
g...@lexort.com>
---
dev/with-tty | 40 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/dev/with-tty b/dev/with-tty
index c65aa1d4..e7616a0b 100755
--- a/dev/with-tty
+++ b/dev/with-tty
@@ -7,11 +7,37 @@ set -ueo pipefail
usage() { echo 'Usage: with-tty command [arg ...]'; }
misuse() { usage 1>&2; exit 2; }
+# script(1), originating in 3.0BSD, is not specified by POSIX and has
+# varying forms.
+
+# FreeBSD 15: script [-aeFfkqrw] [-t time] [file [command ...]]
+# FreeBSD 14: script [-aeFfkqr] [-t time] [file [command ...]]
+# FreeBSD 13: script [-aefkqr] [-F pipe] [-t time] [file [command ...]]
+# FreeBSD 12: script [-adfkpqr] [-F pipe] [-t time] [file [command ...]]
+# FreeBSD 11: script [-adfkpqr] [-F pipe] [-t time] [file [command ...]]
+# FreeBSD 10: script [-adfkpqr] [-t time] [file [command ...]]
+# FreeBSD 8: script [-akq] [-t time] [file [command ...]]
+# FreeBSD 3.0: script [-a] [-k] [-q] [-t time] [file] [command ...]
+# FreeBSD 1.0: script [-a] [file]
+
+# Linux ?: script [options] [file] [-- command [argument...]]
+# but also "-c, --command command", and -eq
+
+# macos ?: script [-aeFkqr] [-t time] [file [command ...]]
+
+# NetBSD 10: script [-adefpqr] [-c command] [file]
+# NetBSD 6-9: script [-adfpqr] [-c command] [file]
+# NetBSD 5: script [-adpr] [file]
+
+
if script -qec true /dev/null; then
- # linux flavor
+ # Linux and NetBSD 10+
script -qec "$(printf ' %q' "$@")" /dev/null
+elif script -q -c true /dev/null; then
+ # NetBSD 6-9
+ ktrace -i -f with-tty.ktrace script -q -c "$(printf ' %q' "$@")" /dev/null
elif script -q /dev/null true; then
- # bsd flavor
+ # FreeBSD and macOS
script -q /dev/null "$@"
else
rc=0
@@ -23,3 +49,13 @@ else
fi
exit 2
fi
+
+case `uname` in
+ NetBSD)
+ # On NetBSD, the top-level script(1) process exits when read()
+ # reports EOF on stdin; this happens when running tests with
+ # /dev/null as stdin. As a workaround, wait after script, so
+ # that the command will have finished.
+ sleep 5
+ ;;
+esac
--
2.51.0