The size (3rd) argument should be ignored if the 1st *dest is NULL, but it seems gcc & glibc headers
are more pedantic now:
ext-utils/pg.c:456:13: error: argument 1 is null but the corresponding size argument 3 value is 2048 [-Werror=nonnull]
Signed-off-by: Karel Zak <kzak@redhat.com>
When invoking hexdump as hd enable the "Canonical" format to by
default, implying the -C option.
This is historic behaviour on Debian and apparently also on FreeBSD.
Some Debian users have asked for this to be restored, after Debian
switched to util-linux' hexdump and hd.
Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
The wording "allow(s) to" is not grammatical English. Reword various
pages to use a more correct form such "can be use to" or "allows
the [noun] of".
Aklong the way, fix a few nearby wording errors in some pages.
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
Commit I made while back and has been part of util-linux v2.30 to v2.35 made
col(1) not to output anything when first line did not have newline character.
printf "gone from output" | col
This commit fixes the issue. Admittedly the col source code is unnecessarily
hard to work with. It could be a good idea to refactor the col(1) as low
priority task, Assuming refactoring is done the first commit to get that done
should add tests that exhaust all possible input handling including all command
line option directives.
Addresses: https://github.com/karelzak/util-linux/issues/422
Fixes: b6b5272b03
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
In several pages, there is a consistent wording problem: "another"
where "other" should be used. This wording problem can be
surprisingly confusing for native speakers, especially those
unaware that in some other languages, "another" and "other" can be
expressed with the same word.
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
Earlier, I patched various pages to consistently use EXAMPLE as a
section heading, rather than EXAMPLES. (At that time, both headings
occurred in util-linux, with roughly equal frequency.)
Since then, I've observed that EXAMPLES is the more common usage
across a large corpus of manual pages. So, in Linux the man-pages
project, I switched to using EXAMPLES also. This patch makes the same
change for util-linux.
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
My earlier change that took libmagic in use to identify mime-type of an input
file caused empty files to be marked binary. Before the change empty files
were simply displayed as empty. This change will restore that behavior.
Addresses: 09070e1a65
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.
In this patch, we ensure that the NOTES, HISTORY, BUGS, and EXAMPLE
sections are always placed near the end of the page, just above
AUTHORS, COPYRIGHT, SEE ALSO, and AVAILABILITY.
One page is not fixed by this patch: term-utils/agetty.8. This page
is a mess of unusual section names, and probably requires an individual
edit.
Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
[Apply patch]
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
$ diff a b
$ echo $?
0
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
There is value in ensuring that manual page sections use consistently
named sections, as far as possible, and also that sections have a
consistent order within manual pages. This is one of a series of patches
to place manual page sections in a consistent order.
In this patch, we ensure that the AUTHORS, COPYRIGHT, SEE ALSO, and
AVAILABILITY sections are always placed at the end of the page.
Testing that no gross editing mistake (causing accidental loss or addition
of text) was performed as follows:
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > a
[Apply patch]
$ cat $(grep '\.SH' -l $(find . -name '*.[1-9]') |sort) | sort > b
$ diff a b
$ echo $?
0
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
There is quite some value (in terms of readability and user
expectations) if consistent names are used for the sections
within manual pages. This patch is one of a series to bring
about this consistency.
But, let's make sure that the section is consistently titled
across pages. Currently we have ENVIRONMENT (many) or ENVIRONMENT
VARIABLES (3). Let's standardize on ENVIRONMENT (which is also
what is suggested in man-pages(7)).
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
There is quite some value (in terms of readability and user
expectations) if consistent names are used for the sections
within manual pages. This patch is one of a series to bring
about this consistency.
Currently we have STANDARDS (3) or CONFORMING TO (6).
Let's standardize on the latter (which is also what is
suggested in man-pages(7)).
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
There is quite some value (in terms of readability and user
expectations) if consistent names are used for the sections
within manual pages. This patch is one of a series to bring
about this consistency.
Currently we have EXAMPLE (10) or EXAMPLES (23).
Let's standardize on the EXAMPLE (which is also what is
suggested in man-pages(7)) and used consistently across
a large number of pages in the Linux man-pages project.
(I realize the choice to go EXAMPLE, rather than EXAMPLES,
may be debatable. If necessary, I'd write a patch that instead
goes the other way, but I'd prefer to follow man-pages(7).)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Using double quotes in .SH lines containing multiple words is unneeded,
and in any case is not consistently done in the util-linux manual pages,
where double quotes are used in only around half of the cases.
(This usage was long ago elminated in the man-pages project, with
no ill effects reported to date.)
Remove these quotes, so that .SH lines are more uniform, in preparation
for some (more easily) scripted doiscovery of consistency problems in
(and possibly global fixes to) the manual pages.
Other than stripping the double quotes, this patch makes no changes to
the content of the manual pages.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
Output is from: test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z
[ "test-groff" is a developmental version of "groff" ]
Input file is ././misc-utils/kill.1
<./misc-utils/kill.1>:173 (macro BR): only 1 argument, but more are expected
Input file is ././misc-utils/lsblk.8
troff: backtrace: '/home/bg/git/groff/build/s-tmac/an-old.tmac':478: macro 'BR'
troff: backtrace: file '<./misc-utils/lsblk.8>':122
troff: <./misc-utils/lsblk.8>:122: warning: trailing space
Input file is ././sys-utils/mount.8
an-old.tmac: <./sys-utils/mount.8>:2427 (.RE): warning: extra .RE or .RS is missing before it; "an-RS-open" is 0.
Input file is ././sys-utils/unshare.1
<./sys-utils/unshare.1>:176 (macro BR): only 1 argument, but more are expected
<./sys-utils/unshare.1>:181 (macro BR): only 1 argument, but more are expected
<./sys-utils/unshare.1>:240 (macro BR): only 1 argument, but more are expected
<./sys-utils/unshare.1>:246 (macro BR): only 1 argument, but more are expected
Input file is ././term-utils/agetty.8
troff: backtrace: file '<./term-utils/agetty.8>':130
troff: <./term-utils/agetty.8>:130: warning: trailing space
Input file is ././text-utils/more.1
troff: backtrace: file '<./text-utils/more.1>':91
troff: <./text-utils/more.1>:91: warning: macro 'b' not defined
The output from nroff and troff is unchanged, except for the word
"number" in text-utils/more.1, that was missing.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Aim was to introduce page and arrow up/down keys to more(1), but that
also required merging colon_command() and more_key_command() functions.
The more_key_commands enum is pointless from computers point of view.
The command identification performed in read_command() inline with
more_key_command() execution -- but that would be hard for humans, and
source code ought to serve both parties.
Reference: https://github.com/karelzak/util-linux/pull/1003
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
As the old commend said: 'This code would best be shared with the file(1)
program or, perhaps, more should not try to be so smart'. Now at configure
time one can choose whether more(1) is sharing code with file(1), or not.
Addresses: http://bugs.debian.org/139205
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Moving backwards has worked fine until reaching start of file. At that
point more printout had one line too much in output causing more seemingly
never to be able to reach the start. That is now fixed, with clean ups to
skip_backwards() making it less confusing.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit also includes fix to how initial skip lines and search are
instructed in the code. Earlier version was pretty close impossible to make
work with getopt_long() and had minor flaw - if both initial skip lines and
search were defined at the same time the skipping did not happen. That is
now corrected.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
When suspending only the more process. Sending signal to process group
makes signal destination unnecessarily vague. After the suspend is over
SIGCONT is expected, and it needs to ensure output terminal settings are
what more needs.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The wait() is now a little more robust by being more tolerate rogue SIGCHLDs
and unblocked signals. The repeated fork() and sleep() is removed, if first
try does not success give up without delay to provide user timely feedback.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
If streams need to be flushed do not try to be clever, just flush all of
them. That lead to finding unnecessary print out in run_shell() that is
removed in this commit.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The sys/ttydefaults.h can be used for CTRL() and rubout that is CERASE. For
alarm it's best to keep things simple and call printf() alarm modifier.
QUIT was not in use, so it is just deleted.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
As a minor robustness improvement use ftello() to find out file position
rather than add and substract from old value.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Use the backspace provided dy terminfo, and if that is not possible use
fallback.
Simplify entering and exiting standard mode. Now when these std_enter and
std_exit variables are initialized correctly they do not need to be checked
quite as complex way as earlier.
Do not call prepare_line_buffer() unnecessarily. The line buffer needs only
to be prepared only at times of more(1) initialization and when terminal
size changes.
Add a function to print various separators, that is better than static
strings.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Earlier main() inline code implemented input files and stdin displaying
separately. With small restructuring this code can be shared.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Return rather than use long 'else' statement. Also unwind some overly
compact variable set and test code, that can be best observed how
underlining settings are now handled.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Currently open file is needed a bit here and there. Move it to control
structure to avoid passing it around. This also makes fixing memory leak at
more_exit() very easy.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This change also removes a ghost prompt that was left in place when printing
help. When looking old commits the output fluke has been around at least
since util-linux v2.2.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Replacing long 'else' with 'continue' allows dropping one level of
indentation. Main aim is to improve code readability by reducing
complexity one needs to keep track while looking the code.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Pagers are not expected to have setuid or setgid bits, but assuming such
mistake has taken place try to avoid privilege escalation.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This change has three possitive effects: Avoid expansion code when it is
not needed. Stop wasting memory from stack for something rarely needed.
When command buffer is needed stop limiting it's size artificially.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
From man siglongjmp(3) 'longjmp() and siglongjmp() make programs hard to
understand and maintain. If possible, an alternative should be used.' That
manual page remark summarizes quite well why more(1) needs to move away from
jumping around.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Let's add "Arguments:" section to the --help output and describe
{K,M,G...}iB suffixes there.
Addresses: https://github.com/karelzak/util-linux/pull/917
Co-Author: ed <ed@s5h.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
Change a HYPHEN-MINUS (code 0x55, 2D) to a minus (\-), if in front of
1) a name of an option
2) a negative number to be printed.
See man-pages(7) [Debian package "manpages"].
The output from "nroff" is unchanged.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Add a comma (,) after "e.g." and "i.e.", or use English words
(man-pages(7) [package "manpages"]).
Abbreviation points should be protected (usually with the
non-printing, zero width character '\&') from being interpreted as an
end of sentence, if they are not, and that independent of their current
place on the line.
This is important when typing, as one does not usually know in
advance when the editor jumps to a new line.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Add or remove one of the pairs .RS/.RE to make their number equal.
The output from "nroff" and "groff" is unchanged.
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Unfortunately methods I used to find and fix were based on quite manual
process that cannot be easily repeated so I do not see how this fix could be
turned into a tools/checkmans.sh addition. Well, lets hope doing this
manually twice every decade is good enough.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The following commands manifests the problem. In old versions before
commit 4762ae9d60 ("column: use libsmartcols for --table"), both of them
should output with 2 "|"
echo '||' | column -o '|' -s '|' -t
echo '|| ' | column -o '|' -s '|' -t
Fixes: 4762ae9d60 ("column: use libsmartcols for --table")
Signed-off-by: Yousong Zhou <zhouyousong@yunionyun.com>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Historical versions of column have described the default fill order as
rows-then-columns and the -x order as columns-then-rows. This was
misleading at best, and the util-linux implementation was updated to
clarify the actual behaviour in 3e094e5fe2 (March 2017).
However, the other implementations (used by *BSD, macOS, Debian, &al.)
continue to use the previous wording, and a user comparing them could
easily get the false impression that util-linux column has exactly the
opposite fill behaviour from BSD column.
To address this, a note is added to the man page explaining the change
and clarifying that, despite what the BSD documentation says, the two
implementations behave identically in this regard.
Signed-off-by: dana <dana@dana.is>
The code is horrible. The core of the problem are signed integers
and no check for the limits.
This patch fixes c->c_column = cur_col; where c_column is "short"
and "cur_col" is int. Let's use "int" for all the variables. It's
really not perfect as for bigger lines it can segfault again...
The patch also removes some unnecessary static variables.
Addresses: https://github.com/karelzak/util-linux/issues/749
Signed-off-by: Karel Zak <kzak@redhat.com>
First three fixes on lines 133, 151, and 280 are cosmetic. Because there
was unobvious null check compiler thought variable might be null, and warned
when after pointer adjustment it was followed without null check. Perhaps
this will not happen sometime in future when compiler is made more smart,
meanwhile lets give better hints to avoid false positive.
The last change addresses issue that is possible, at least in theory.
text-utils/hexdump-parse.c:465:12: warning: potential null pointer
dereference [-Wnull-dereference]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Try to make variable names to tell what they do. Earlier names have been in
more(1) since the command was first wrote, and it looks like coding
practices has changed since late 70's.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
One can only assume someone tried to make more(1) to run quicker. More up
to date assumption is that compilers are fully capable optimizing binaries
without these sort of hints.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The curs_terminfo(3X) defines putp() as tputs(str, 1, putchar), so all of
these five functions can be replaced with putp().
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Removal of STOP requires explanation. Looking unix-history-repo getline()
function in first BSD-3 version could return STOP. By next tag BSD-4 the
return STOP had disappeared. If I read this correctly that was a partial
removal, and second part has waited to be completed since 1980-11-16 when
BSD-4 was released.
Reference: https://github.com/dspinellis/unix-history-repo/blob/BSD-3-Snapshot-Development/usr/src/cmd/more.c#L501
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The option allows to add empty line to the table. The default behavior
is to ignore empty lines at all.
echo -e "A\nAA\nAAA\n\nAAAA" | ./column --table
A
AA
AAA
AAAA
$ echo -e "A\nAA\nAAA\n\nAAAA" | ./column --table --table-empty-lines
A
AA
AAA
AAAA
Addresses: https://github.com/karelzak/util-linux/issues/593
Signed-off-by: Karel Zak <kzak@redhat.com>
A developmental version of "groff" issued a warning, for example with
"test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z":
troff: <logger.1>:299: warning: can't find font 't'
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Inlining code using preprocessor function like macros is bad for
readability, and prone to errors. Besides this is a pager, who cares if
code is few milliseconds slower.
Requestee-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This is rather big change, but that is the only way to do this sort job. To
keep this change relatively understandable only moves global variables to a
state structure.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Earlier commit moved lots of functions to work without declarations, but to
be able to get rid of global variables few more moves is needed.
Reference: a8f98304e6
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Use the correct macro (I, B) for the font change of one argument, not
those that are used for alternating two fonts, like "BR", "IR", "RB",
or "RI".
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Group include, defines and such together, and move items inbetween functions
on top of the source file so that everything can be seen easily.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The bug has been introduced during column(1) rewrite. The function
read_input() need to skip leading space only temporary to detect empty
lines, but the rest of the code has to use the original buffer (line).
I've tried to fix one of the symptoms by 5c7b67fbbf
(alter), but this solution is unnecessary and too complex.
Changes:
* don't ignore leading space
* remove unnecessary stuff introduced by 5c7b67fbbf
* fix regression test with incorrect separator
Addresses: https://github.com/karelzak/util-linux/issues/575
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1560283
Signed-off-by: Karel Zak <kzak@redhat.com>