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>
As per the convention shown in Documentation/howto-man-page.txt.
Also make a few other tiny adjustments along the way.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
It seems better to warn about --reload in ./configure if futimens or
inotify_init1 are missing.
The patch also replaces futimes() with futimens() to make the code
compatible with Uclibc.
Addresses: https://github.com/karelzak/util-linux/issues/133
Signed-off-by: Karel Zak <kzak@redhat.com>
Fix command line parsing to not ignore term setting if no baud
specified, for example:
/sbin/agetty ttyS0 vt100
Signed-off-by: Karel Zak <kzak@redhat.com>
* makes speeds table usage more robust
* don't call next_speed() for empty speeds table to avoid division by zero
* default to 9600 when port baud unspecified
Addresses: https://github.com/karelzak/util-linux/pull/131
Signed-off-by: Karel Zak <kzak@redhat.com>
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>
Add an 'agetty --reload' command which asks all running agetty
commands to display their prompts again.
Several of the /etc/issue escape codes such as \4 and \S depend on
variable data which can change after the agetty prompt is displayed.
This can cause stale data to be displayed when a user looks at a VT,
especially in cases of DHCP racing with system start up.
We never want this to occur once the user has started typing a
user name. So we detect when the user starts typing, after which
no further reprompting occurs after that point.
[kzak@redhat.com: - add #ifdefs to make it usable on non-inotify systems,
- use futimens() with NULL timespec
- add --reaload to usage()]
Signed-off-by: Stef Walter <stefw-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
Mainly: showing that the word color is a placeholder by writing
<color>, showing some numbers as optional, and message levels
and colors as not optional.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
The main changes are: showing the arguments of boolean options
as optional, improving the alphabetization, and restoring the
--half-bright option that went missing in 2011.
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
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>
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>
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>
Underline option arguments, and use bold for options. Avoid use of \f
font style change in paragraphs, but use them when describing options.
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Commit 3393c136 caused regression. The klogctl() logging range is 1-8,
but the value 0 is special according to setterm.1 manual page. It turns
on loging, same way as '-msg on' option.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
It is enough trouble to keep usage output aligned with getopt() parsing,
manual page, and bash-completion, so get rid of the unnecessary effort
duplication.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Earlier the function was in the middle of option parsing code segment,
and screendump() required function prototype.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Check the input numbers are numbers, which makes also the code shorter,
and user experience better as half invalid imputs will error.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
While the -version style options will work for next unknown number of
years start moving towards user interface that has way of invoking long
options as most of the other commands.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The getopt_long_only() has advantage of allowing one and two hyphen
versions of options, for example -help and --help. Secondly the getopt
function family from libc can ensure some options requiring arguments,
while other are optional, and some should not accept argument at all.
That makes option parsing more robust.
Unfortunately retiring the old option parsing makes this change greater
than preferred. Assuming not mistakes happen the new code works
functionally exactly as the old did.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The issue file escape sequences \4 and \6 prints the host IP when no
interface is specified. That's useless on some virtual machines where
gethostname()+getaddrinfo() returns 127.0.0.1.
The seems better to print IP of the "best" interface (UP, RUNNING, non-LOOPBACK)
and use gethostname() as painful fallback only.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1090935
Signed-off-by: Karel Zak <kzak@redhat.com>
For this approach do not use the ioctl TIOCMGET anymore as this
is for real serial lines only. But switch over to use the ioctl
KDGKBMODE as this is unique to the virtual console lines only.
Signed-off-by: Werner Fink <werner@suse.de>
That is that there are several consoles, the /dev/ttyS0 which
is type of ibm3215 and a dumb terminal, then there is the device
/dev/3270/tty1 which can handle ANSI color escape sequences and is
a ibm327x terminal, and the /dev/ttyS1 which is a vt220 terminal.
The macro is_speed() in agetty.c allows to distinguish between the
terminal line (/dev)3270/tty1 and the speed options on the command
line used in
/run/systemd/generator/getty.target.wants/serial-getty@3270-tty1.service
which is a symbolic link to /usr/lib/systemd/system/serial-getty@.service
Signed-off-by: Werner Fink <werner@suse.de>
The nowadays used plymouth locks the devices used for the system
console which causes that agetty as well as sulogin can not modify
the termios settings of e.g. the serial devices of the systenm console.
Signed-off-by: Werner Fink <werner@suse.de>
Remove various magic numbers with either a string lenght count, or a
symbolic variable that is recognized by gdb.
[kzak@redhat.com: - use snprintf() everywhere,
- check snprintf() return code rather than mess up
the code with strlens]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
* 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>
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>
This option caps the delay between updates, to avoid long pauses in
transcript playback.
Signed-off-by: Jesper Dahl Nyerup <nyerup@one.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Let's use nanosleep() although if usleep() exists. The nanosleep
function does no interact with signals and other timers.
The patch introduces xusleep() as replacement to libc (or our fallback)
usleep(). Yes, we don't want to use struct timespec + nanosleep()
everywhere in code as nano-time resolution is useless for us.
The patch also enlarges delays in some busy wait loops. It seems
enough to try read/write 4x per second.
Signed-off-by: Karel Zak <kzak@redhat.com>
- 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>
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>
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>
It seems that setterm -dump does not dump terminal attributes, but
the man page says -dump includes the attributes. Let's fix the man
page.
Reported-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
which is due legacy reasons a block terminal of type 3270 or higher.
Whereas the second serial line on a S/390(x) is a real character
terminal which is compatible with VT220.
Signed-off-by: Werner Fink <werner@suse.de>
* it seems that we don't have to link the utils with ncurses, tinfo is enough.
This change saves one unnecessary dependence.
* libtinfo is also distributed with pkg-config files, so we can use
PKG_CHECK_MODULES() as a primary source for LIBS and CFLAGS.
* add TINFO_CFLAGS (although it's probably always empty)
Signed-off-by: Karel Zak <kzak@redhat.com>
If we are not on glibc, __GNU_LIBRARY__ will not exist causing the check
to always fail and try to use syscalls directly.
Signed-off-by: Karel Zak <kzak@redhat.com>
sys/types.h: For u_char typedef
sys/params.h: For MAXNAMLEN
sys/ttydefaults.h: For various tty definitions (also add configure check)
Signed-off-by: Karel Zak <kzak@redhat.com>
The ncurses package has been providing pkg-config files for a while now.
So let's start using them to get the proper linker & compiler flags. It
can make a difference when ncurses is configured in a way that requires
extra link time flags but util-linux doesn't provide them, or when the
headers live in a weird place and util-linux can't find them.
Since the NCURSES_LIBS is always defined for the Makefile, there's no need
to gate on the HAVE_NCURSES conditional. When it's disabled, the var will
simply be empty.
With a minor tweak to how tinfo is handled, we can do the same thing -- we
just always use TINFO_LIBS in the Makefile's.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
The ncurses term.h header has logic in it to detect if nucrses.h has
already been included and void defining things when it has. But since
setterm includes term.h and the ncurses.h, it doesn't work and we can
get fun build-time warnings like:
CC term-utils/setterm-setterm.o
In file included from term-utils/setterm.c:109:0:
/usr/include/ncursesw/ncurses.h:827:12: warning: redundant redeclaration of 'tigetflag' [-Wredundant-decls]
extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *); /* implemented */
^
In file included from term-utils/setterm.c:106:0:
/usr/include/ncursesw/term.h:775:12: note: previous declaration of 'tigetflag' was here
extern NCURSES_EXPORT(int) tigetflag (NCURSES_CONST char *);
^
Signed-off-by: Mike Frysinger <vapier@gentoo.org>