Commit Graph

153 Commits

Author SHA1 Message Date
J William Piggott 4111bb3ab5 lib/timeutils: add common ISO timestamp masks
* Start the ISO format flags at bit 0 instead of bit 1.

* Remove unnecessary _8601 from ISO format flag names to
  avoid line wrapping and to ease readability.

* ISO timestamps have date-time-timzone in common, so move
  the TIMEZONE flag to bit 2 causing all timestamp masks
  to have the first three bits set and the last four bits
  as timestamp 'options'.

* Change the 'SPACE' flag to a 'T' flag, because it makes
  the code and comments more concise.

* Add common ISO timestamp masks.

* Implement the ISO timestamp masks in all applicable code
  using the strxxx_iso() functions.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-11-10 16:34:55 -05:00
Karel Zak d88b739fba script: simplify stdin usage in poll()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-18 11:49:11 +02:00
Karel Zak 2e7a922701 script: support sig{stop/cont}
* call wait() only when child exited
* suspend all session (including script master process) when child get
  SIGSTOP and send SIGCONT to child when master process resume

This allows to suspend all session and later use "fg" shell command to
resume.

$ ps af
14722 pts/1    Ss     0:00 bash
 4870 pts/1    S+     0:00  \_ ./script
 4871 pts/6    Ss+    0:00      \_ bash -i

$ kill -SIGSTOP 4871

and script session on another terminal:

$ script
Script started, file is typescript
$ 
[1]+  Stopped                 ./script

$ fg 1
./script

... session again usable ...
^D
Script done, file is typescript

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-08 09:48:29 +02:00
Antonio Ospite 3cf274c9e9 script: fix ambiguity about the optional argument of the -t option
[kzak@redhat.com: - merge two patches from Antonio to the one,
                  - update the patch]

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Antonio Ospite <ao2@ao2.it>
2017-07-18 14:29:07 +02:00
Ruediger Meier f45f3ec34a misc: consolidate macro style USAGE_HELP_OPTIONS
changed in include/c.h and applied via sed:

  sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
  sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-29 16:54:33 +02:00
Ruediger Meier b305445495 misc: consolidate all --help option descriptions
Now we are always using the same text also for commands
which had still hardcoded descriptions or where we can't
use the standard print_usage_help_options macro.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-27 12:28:36 +02:00
Karel Zak 47ccf06b47 Merge branch 'usage-part2' of https://github.com/rudimeier/util-linux
* 'usage-part2' of https://github.com/rudimeier/util-linux:
  misc: cosmetics, remove argument from usage(FILE*)
  misc: cosmetics, remove argument from usage(int)
  misc: never use usage(stderr)
  misc: never use usage(ERROR)
  misc: cleanup and fix --unknownopt issues
  flock, getopt: write --help to stdout and return 0
  tools: add checkusage.sh
2017-06-26 15:58:37 +02:00
Karel Zak 7fb65db124 script: rename fixtty() to enable_rawmode_tty()
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-26 15:30:12 +02:00
Sami Kerola 8198052c9e script: ensure typescript and timing errors do not break terminal
Earlier when typescript file failed new line after the error did not cause
carriage return.  Here is an example how prompt> travels to wrong place:

prompt> script 0500-perms/typescript
Script started, file is 0500-perms/typescript
script: cannot open 0500-perms/typescript: Permission denied
                                                            prompt>

But that wasn't quite as bad as what happen with timing file, that at
failure left terminal to state where a reset(1) run was needed.

[kzak@redhat.com: - move code to restore_tty()]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-26 15:23:31 +02:00
Ruediger Meier 86be6a32d3 misc: cosmetics, remove argument from usage(FILE*)
This patch is trivial and changes nothing, because
we were always using usage(stdout)

Now all our usage() functions look very similar. If wanted we
could auto-generate another big cosmetical patch to remove all
the useless "FILE *out" constants and use printf and puts
rather than their f* friends. Such patch could be automatically
synchronized with the translation project (newlines!) to not
make the translators sick.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Karel Zak 6f3c9c3430 script: always write stat and done message to typescript file
And remove usec from timestamp.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-18 12:12:44 +02:00
Rui Zhao (renyuneyun) bdef362d5d fix the position of newline in the time output of 'script'
- move '\n' to fprintf
- use `timeutils/strtime_iso()` instead of `strtime()`

Signed-off-by: Rui Zhao (renyuneyun) <renyuneyun@gmail.com>
2017-04-14 17:49:25 +01:00
Karel Zak d05422417e script: don't call strftime() if not necessary
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-04-13 15:06:52 +02:00
Rui Zhao (renyuneyun) 493548b85d script: fix start message showing in output file when -q is on
Signed-off-by: Rui Zhao (renyuneyun) <renyuneyun@gmail.com>
2017-04-05 21:11:13 +01:00
Sami Kerola 2ba641e5f3 misc: add static keyword to where needed [smatch scan]
text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be
static?

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Bert van Hall 8d6fdd2f0c
term-utils/script: fix typo leading to syntax error
Introduced in edc7e42, this typo is actually invalid C. Fix this.

Signed-off-by: Bert van Hall <bert.vanhall@avionic-design.de>
2017-01-18 16:45:56 +01:00
Karel Zak 677ec86cef Use --help suggestion on invalid option
The current default is to print all usage() output. This is overkill
in many case.

Addresses: https://github.com/karelzak/util-linux/issues/338
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 13:13:34 +01:00
Karel Zak 53ca053291 script: improve coding style and the "done" message
Don't print the "done" message if the file does not exist.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-18 15:06:31 +02:00
Sami Kerola 22d5cc87e6
script: check status of writes when closing outputs
This should make possible output issues more obvious, for example when a
disk will get full.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-16 23:09:26 +01:00
Sami Kerola 4b0b416acb
script: avoid trying fclose(NULL)
Here is a one-liner to reproduce the issue.

$ mkdir example && cd example && chmod 0500 . && script
Script started, file is typescript
script: cannot open typescript: Permission denied
                                                 Script done, file is typescript
Segmentation fault (core dumped)

Addresses: https://bugs.launchpad.net/bugs/1537518
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-16 23:09:26 +01:00
Sami Kerola 760e5e682d
script: close file descriptors on exec
The commands spawned from script(1) will never need access various file
descriptors the script(1) is using.

Reviewed-by: Ruediger Meier <sweet_f_a@gmx.de>
Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-16 23:09:26 +01:00
Karel Zak b2bff06661 script: use empty-slave heuristic more carefully
script(1) waits for empty slave FD (shell stdin) before it writes to
master. This feature has been intorduiced by 54c6611d6f
to avoid misbehavior when we need to send EOF to the shell.

Unfortunately, this feature has been used all time for all messages.
This is wrong because command in the session (or shell) may ignore
stdin at all and wait forever in busy loop is really bad idea. Test
case:

 script /dev/null
 tailf /etc/passwd
 <enter>
 <enter>

... script process taking 100% CPU.

This patch forces script to use empty-stave detection only when we
need to write EOF. The busy loop has been modified to use nanosleep
and it does not wait forever...

Addresses: http://bugs.debian.org/820843
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-13 11:52:43 +02:00
Ruediger Meier 7231fb2a5b misc: fix some printf format strings
Fix the warnings below for OSX clang and add a few more
casts for timeval:

lib/at.c:131:27: warning: format specifies type 'intmax_t' (aka 'long') but the argument has type 'off_t' (aka 'long long') [-Wformat]

                        printf("%16jd bytes ", st.st_size);

                                ~~~~~          ^~~~~~~~~~

lib/strutils.c:522:52: warning: format specifies type 'intmax_t' (aka 'long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]

                snprintf(buf, sizeof(buf), "%d%s%jd%s", dec, dp, frac, suffix);

                                                ~~~              ^~~~

lib/sysfs.c:468:42: warning: format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Wformat]

        len = snprintf(buf, sizeof(buf), "%ju", num);

                                          ~~~   ^~~

libuuid/src/gen_uuid.c:316:34: warning: format specifies type 'unsigned long' but the argument has type '__darwin_suseconds_t' (aka 'int') [-Wformat]

                              clock_seq, last.tv_sec, last.tv_usec, adjustment);

                                                      ^~~~~~~~~~~~

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-11 13:39:56 +01:00
Ruediger Meier 23e35eca15 script: fix misspelling 2016-02-03 16:34:12 +01:00
Ruediger Meier 3fd1f7711e docs: fix typos found by codespell
Using "codespell" from https://github.com/lucasdemarchi/codespell

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-03 15:10:08 +01:00
Sami Kerola a4aeb5bd80 script, hwclock: check file exist with access(3) rather than stat(3)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-11-09 09:56:14 +01:00
Karel Zak c2f03da93d script: be pedantic and use "%"SCNi64
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-16 11:48:47 +02:00
Isaac Dunham 345208a5ab script: don't assume that time_t is compatible with long
time_t may change to 64-bit on 32-bit Linux kernels at some point;
at that point, it may be desireable to test for issues with dates
past 2038.

[kzak@redhat.com: - use %jd rather than %lld]

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-16 11:31:22 +02:00
Karel Zak 5860c45eed script: improve SIG{TERM,QUIT,KILL} sensitivity
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-28 10:36:29 +02:00
Ruediger Meier 7dbcd80ee8 script: evaluate errno only if read() sets it
[kzak@redhat.com: - be careful with errno and DBG
                  - add EINTR check
                  (both suggested by Rudi]

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-03 09:53:05 +02:00
Karel Zak e831c87670 script: make sure errno is zero
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-02 10:30:10 +02:00
Sami Kerola 0664d41dba script: fix variable initialization warning
term-utils/script.c:402:19: warning: obsolete use of designated
initializer without '=' [-Wpedantic]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 12:05:25 +02:00
Karel Zak 54c6611d6f script: fix EOF problems
* remove STDIN from poll() if:

  * STDIN already closed -- poll returns POLLHUP, for example:

		echo "date" | script

  * detect EOF as returned by read(), for example:

		script -c "echo Hello" < /dev/null

* don't write to master when there is still something to read from
  slave (it means shell is not initialized yet or busy)

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-17 15:48:50 +02:00
Karel Zak 2e9418b7cc script: improve poll debugging
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-17 13:33:35 +02:00
Karel Zak d35ffe808a script: cleanup signals usage
* don't call anything from assert()
 * fork() block cleanup to make it more readable
 * restore original signal mask in child (do_shell())
 * close signal FD in child (do_shell())

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-17 13:25:46 +02:00
Karel Zak 1200cfbfbd script: debug poll() results
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-16 14:44:05 +02:00
Karel Zak a2b4dec553 script: add support for SCRIPT_DEBUG=
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-16 14:03:09 +02:00
Karel Zak da26af4ee1 script: remove magic constants from poll code
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-16 13:11:05 +02:00
Karel Zak 3f19b85f97 script: rename control struct members
Sorry, but it's really ugly manner to use "xflg" where "x" is a command
line option as program variable and use it in code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-16 12:34:04 +02:00
Karel Zak 7e5796c916 script: close timingfp also when -e
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-16 12:26:00 +02:00
Sami Kerola 9580536a7f script: move timing file opening close to use of it
This allows removing almost immediate closure of file handle in the
doshell() function that does not use the file.

Proposed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:53:37 +01:00
Sami Kerola 2ddadb5eda script: add noreturn function attributes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:53:37 +01:00
Sami Kerola 04639805e1 script: use gettime_monotonic() to get timing file timestamps
This moves the previous time to script control structure, and does
timeval calculation with timersub() that is more appropriate than
making a timeval to a double.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:53:36 +01:00
Sami Kerola b09feab9e4 script: use correct input type, move comment, and so on
Minor corrections.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:53:36 +01:00
Sami Kerola 8353549e02 script: replace strftime() workaround with CFLAGS = -Wno-format-y2k
Nowadays, gcc(1) provides the -Wno-format-y2k option to prevent the
warning, so that the above workaround is no longer required.

Reference: http://man7.org/linux/man-pages/man3/strftime.3.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:53:36 +01:00
Sami Kerola a8896ad5b7 script: move do_io() content to small functions
The do_io() got to be a bit long with relatively deep indentation.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:53:34 +01:00
Sami Kerola 076ffa48f3 script: add 'Script started' line always to capture file
The scriptreplay(1) will expect capture file always to have header.
Before this change the --quiet option together with timing caused
following replay error.

$ script --quiet --timing=timing
[...]
$ scriptreplay timing typescript
[...]
scriptreplay: unexpected end of file on typescript

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:52:51 +01:00
Sami Kerola 89a859d433 script: remove io vs signal race
Make do_io() to run poll() until all streams are empty.  This should
remove the signal from child versus io handling race for good.

Addresses: https://github.com/karelzak/util-linux/pull/62
Addresses: https://bugs.launchpad.net/bugs/264967
Addresses: https://bugs.debian.org/305808
CC: Wolfgang Richter <wolf@cs.cmu.edu>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:52:51 +01:00
Sami Kerola 6ddf53a5b4 script: merge doinput() and output() functions to do_io()
One item to poll() more is a lot less work for system than separete input
and output processes.

Addresses: https://github.com/karelzak/util-linux/pull/62
CC: Wolfgang Richter <wolf@cs.cmu.edu>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-08 21:52:36 +01:00
Sami Kerola cf470183ea script: use poll() rather than select()
Finalize the signalfd() change by adding file descriptors to poll() loop.

Addresses: https://github.com/karelzak/util-linux/pull/62
CC: Wolfgang Richter <wolf@cs.cmu.edu>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-06 14:53:56 +01:00
Sami Kerola cc1a88fb59 script: use signalfd() to catch signals
This is incomplete change.  Working command requires the subsequent
select() to poll() change as well.

Addresses: https://github.com/karelzak/util-linux/pull/62
CC: Wolfgang Richter <wolf@cs.cmu.edu>
CC: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-06 14:53:55 +01:00
Sami Kerola edc7e42076 script: add struct script_control and remove global variables
Fix also couple indentation issues.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-06 14:53:50 +01:00
Sami Kerola 93af8d8bf3 script: remove function prototypes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-06 14:36:46 +01:00
Sami Kerola 6a40c65f81 tests: check script options work as expected
Options --flush and --timing remain unchecked, as I do not have an idea
how to check them reliably.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-06 14:36:38 +01:00
Stanislav Brabec 8fdc064ac3 script: Fix mangled EOF and hang on big endian
On s390 and other big endian machines, doinput() sends NUL instead of
EOF to the tty master. NUL does not even reach the slave, and it is
waiting for more data forever.

If STDIN is not a tty, the bug caused "^@" being into the log, and since
commit 032228c it also causes hang.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2015-05-15 12:56:46 +02:00
Stanislav Brabec 0b285b84b2 Fix "Script started" buffering race
script -c "echo Hallo World" </dev/null >script.log ; cat script.log

Before:
Hallo World
Script started, file is typescript
Script started, file is typescript
Script done, file is typescript

After:
Script started, file is typescript
Hallo World
Script done, file is typescript
2015-02-10 11:18:51 +01:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Andreas Henriksson 032228c9af script: may be hangs
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-14 12:07:21 +02:00
Sami Kerola db433bf737 textual: use usage() text element macros
Translating these text elements should happen only once, which is
more likely when the text macros are used properly.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:26 +02:00
Sami Kerola a587cc5520 textual: use manual tail usage() macro
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:24 +02:00
Sami Kerola f627750083 textual: use version printing macro everywhere
Only mount, umount, and blkid remains not using the macro because they
are print also library references.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:23 +02:00
Karel Zak cabce4ea71 script: clean up code to genenrate Star/Done messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-23 11:41:31 +02:00
Andreas Henriksson dc47cfee48 script: silence the done message on --quiet as well
Apparently James Hunts patch (which he provided a long time
ago) is no longer covering it all.

This followup patch also silences the "Script done ..." message
when --quiet is used.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2014-06-23 11:31:08 +02:00
James Hunt 1474c09ea8 script: --quiet option is not quiet.
Specifying 'script --quiet ...' still produces the 'Script started'
message in the typescript file. The --quiet option implies that the
script program should not log any of its output to the typescript file.

Originally reported at:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=693966

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2014-06-23 11:31:07 +02:00
Karel Zak ee312c654b docs: fix "behaviour" vs. "behavior"
Sometimes we use "behaviour" and "behavior" in the same text, let's
use "behavior" only everywhere.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1011068
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-06 09:49:35 +02:00
Csaba Kos 578a1691f6 script: fix spurious exit from input read loop on EINTR. 2014-06-02 10:14:30 +02:00
Csaba Kos 26ed9fb872 script: fix a rare deadlock after child termination 2014-06-02 10:14:07 +02:00
Wolfgang Richter b0d6b85720 script: time from end of read() call partially fixes #58 2014-03-19 22:45:48 -04:00
Karel Zak 4368e3e687 script: clean up files usage
* don't initialize timingfd (to stderr) when -t not specified

 * care about timingfd dooutput() rather in main()

 * make timingdf gloval like fscript FILE

 * close all in done()

 * close irrelevant things in subshell and input processes

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-02-21 13:39:14 +01:00
Jesper Dahl Nyerup 5d0ce5e84f script: Also flush writes to timing file.
If both -f and -t are given, flush the timing fd on each write, similar
to the behavior on the script fd. This allows playback of still-running
sessions, and reduces the risk of ending up with empty timing files when
script(1) exits abnormally.

Signed-off-by: Jesper Dahl Nyerup <nyerup@one.com>
2014-02-21 13:16:20 +01:00
Karel Zak c6fca22e3a script: use all-io.h to make the code more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-16 14:44:37 +01:00
Karel Zak 968e632cdb script: fix inconsistent -q, use poll() rather then O_NONBLOCK
- don't suppress "Script done" message in typescript file by -q
   (note that -q has no effect to "Script started" message)

 - simplify the code by poll()

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-16 13:18:24 +01:00
Karel Zak 38374be4c8 script: don't wait for empty descriptors if child is dead
The current code waits for empty file master and slave descriptors,
but it makes sense only if there is child process that cares (read)
about data in the descriptors.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-16 12:22:13 +01:00
Karel Zak 3822032da3 script: script input redirection / eof handling
echo "ps uf" | script

does not work because script assume that stdin is terminal and
it does not forward EOF to the pty.

This patch:

  * make non-tty use-case more robust (don't call tty ioclts to
    non-tty file descriptors.

  * send EOF (CTL('D') control char) to the master channel when
    detected eof by read() on stdin

  * wait for empty master and slave file descriptors to be sure that
    we don't miss date for typescript. This is also necessary to be
    sure that slave channel (shell) is completely initialized otherwise
    EOF is ignored.

Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-12-03 13:32:55 +01:00
Karel Zak f50473e7ca script: check that stdin is a terminal
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-12-02 13:42:01 +01:00
Karel Zak 185b1bc7f4 script: restore errno in signal handler
References: https://plus.google.com/+LennartPoetteringTheOneAndOnly/posts/gHSscCJkakd
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-14 14:42:23 +01:00
Karel Zak f630400c4e script: don't call TIOCGWINSZ in signal handler
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-14 14:34:15 +01:00
Karel Zak 3d13d5823f script: use __noreturn__ for really last function [clang -Winvalid-noreturn]
Use 'noreturn' for done() only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-20 15:20:18 +01:00
Benno Schulenberg b50945d4ac textual: spell and encode the name of Arkadiusz Miśkiewicz correctly
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-02-06 11:15:02 +01:00
Sami Kerola b4ff2f54d7 script: search shell from path, when necessary
Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=518532
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-09 13:37:01 +01:00
Sami Kerola 958e39d238 script: do not try to close stderr twice
The commit cdd2a8c360 broke script(1)
return value.

$ script -e -c "echo"; echo $?
1

The reason, as Daniel it reported, was that the script will close stderr
twice, once as timing file and atexit() in function close_stdout().  This
commit fixes the problem.

Reported-by: Daniel Narvaez <dwnarvaez@gmail.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-08 14:51:20 +01:00
Sami Kerola 5da054e070 script: add noreturn function attributes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-26 13:51:33 +02:00
Sami Kerola 289dcc9023 translation: unify file open error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Karel Zak 46e28f0431 script: remove unused code
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-21 12:14:34 +02:00
Sami Kerola 0e9b73d3fb build: fix redundant redeclaration warnings
env.c:24:15: warning: redundant redeclaration of 'environ' [-Wredundant-decls]
su.c:81:15: warning: redundant redeclaration of 'environ' [-Wredundant-decls]

fstab.c:581:14: warning: redundant redeclaration of 'strsignal' [-Wredundant-decls]

kill.h:1:13: note: previous declaration of 'get_pids' was here
kill.c:152:13: warning: redundant redeclaration of 'get_pids' [-Wredundant-decls]

kill.c:142:5: warning: redundant redeclaration of 'main' [-Wredundant-decls]
getopt.c:89:5: warning: redundant redeclaration of 'main' [-Wredundant-decls]

agetty.c:536:15: warning: redundant redeclaration of 'optarg' [-Wredundant-decls]
agetty.c:537:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]
script.c:161:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]
wall.c:96:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls]

libmount.h:362:26: note: previous declaration of 'mnt_update_get_fs' was here
libmount.h:454:26: note: previous declaration of 'mnt_context_get_fs' was here
mountP.h:383:26: warning: redundant redeclaration of 'mnt_context_get_fs' [-Wredundant-decls]
mountP.h:398:26: warning: redundant redeclaration of 'mnt_update_get_fs' [-Wredundant-decls]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 19:51:35 +02:00
Sami Kerola cdd2a8c360 term-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:46:25 +02:00
Sami Kerola d2ec3e33f1 script: error in usage() output
Error originates to commit 3ff526391f
which is bit more than year, and part or releases v2.20 & v2.21.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-02 13:14:20 +02:00
Karel Zak a17f32645d script: play well with csh when invoked from within /etc/csh.login
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=797888
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-08 16:02:28 +01:00
Sami Kerola e11a5e6375 build-sys: check HAVE_ definitions with #ifdef [smatch scan]
Fix to `warning: undefined preprocessor identifier' messages.

[kzak@redhat.com: replace "#ifdef XXX #ifdef YYY" with
                  "#if defined(XXX) && defined(YYY)"]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-02 18:27:12 +01:00
Sami Kerola fbc333fec0 build-sys: check HAVE_ definitions with #ifdef [smatch scan]
Fix to `warning: undefined preprocessor identifier' messages.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-02 18:21:46 +01:00
Karel Zak d36ee054ca script: non-ANSI definition [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-12 16:18:16 +02:00
Karel Zak 4d84fcb4c7 script: libintl.h included in nls.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-07 16:29:56 +02:00
Natanael Copa 3c911718df script: fix building with --disable-nls
We should only include the libintl.h when NLS is requested.

This fixes issue when building util-linux with uClibc.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
2011-09-07 07:30:35 +02:00
Karel Zak 87d6050bb0 script: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-16 13:41:06 +02:00
Benno Schulenberg 51b65a5bf7 script: indicate that the file argument to --timing is optional
Also improve some other descriptions in the usage message.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-15 15:49:48 +02:00
Sami Kerola 05644dabb4 script: remove magic constants and a type mismatch fix
The type mismatch; doinput: int -> ssize_t

[kzak@redhat.com: - int -> pid_t,
                  - remove "register" keyword]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-29 11:31:58 +02:00
Sami Kerola 8fb810ff26 script: include-what-you-use header check
The tool proposed;

script.c should add these lines:

script.c should remove these lines:
- #include <sys/file.h>  // lines 53-53
- #include <sys/types.h>  // lines 48-48
- #include "c.h"  // lines 61-61

and the change nearly did what the tool told. We should keep on
using c.h, not err.h. The config.h is not needed, it's added
automaticly.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-29 11:24:30 +02:00
Sami Kerola 0f81d3289f script: remove unnecessary void casting
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-29 11:23:58 +02:00
Sami Kerola fd4c1f632f script: option --force added
The --force will allow default output destination, e.g.
typescript file, to be hard or symbolic link.

[kzak@redhat.com: - remove "error:" prefix from errx()]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-29 11:22:14 +02:00
Sami Kerola 7ca59ef25f script: optional timing output file argument added
And update to manual page accordingly.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-04-12 14:21:36 +02:00