Commit graph

693 commits

Author SHA1 Message Date
Cristian Rodríguez
e33d586014 pg: calling exit on signal handler is not allowed
On the other hand, calling _exit is just fine.
2023-01-15 01:33:14 +00:00
Karel Zak
09b9b466d4 column: support negative numbers in range
Fixes: https://github.com/util-linux/util-linux/issues/1700
Signed-off-by: Karel Zak <kzak@redhat.com>
2023-01-04 13:59:08 +01:00
Thomas Weißschuh
f74d384e24 rev: allow zero-byte as separator
Fixes #1868
2022-11-13 02:45:41 +01:00
Thomas Weißschuh
d2082bf70e rev: make separator configurable 2022-11-12 20:30:59 +01:00
Thomas Weißschuh
c9cc84621c rev: use pointer-size-pairs instead of C-string
This allows us to properly handle zero-bytes
2022-11-12 20:29:55 +01:00
Karel Zak
ed07532a97 more: update basic command description
Fixes: https://github.com/util-linux/util-linux/discussions/1891
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-11-10 09:39:47 +01:00
Karel Zak
8ac75e31de column: fix greedy mode on -l
In the 'greedy' mode strtok() skips leading white chars, but code for
-l (merge remaining data to the last column) do not count the skipped
chars.

Old version:

$ printf '  a b c\n1 2 3\n' | column -t -o '-' -l2
a-a
1-2 3

Fixed version:

$ printf '  a b c\n1 2 3\n' | column -t -o '-' -l2
a-b c
1-2 3

Note, see leading white chars '  a b c'.

Fexes: https://github.com/util-linux/util-linux/issues/1763
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-08-04 10:21:06 +02:00
Karel Zak
4aacf57da1 column: fix buffer overflow when -l specified
$ printf 'a b c\n1 2 3\n' | column -s : -t -o '-' -l2
a b c-ġ
1 2 3-

Signed-off-by: Karel Zak <kzak@redhat.com>
2022-08-04 10:20:57 +02:00
blacknon
553151462b update. Since the specified column is shifted by one column, subtract it. 2022-06-20 22:56:00 +09:00
Karel Zak
131a443459 column: support ranges when addressing columns by numbers
Fixes: https://github.com/util-linux/util-linux/issues/1723
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-06-20 13:25:59 +02:00
Karel Zak
224410df38 more: (man) add note about POSIXLY_CORRECT
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-06-15 10:15:53 +02:00
Karel Zak
28b391ce7e more: restore exit-on-eof if POSIXLY_CORRECT is not set
In version 2.38, exit-on-eof has been disabled by default. This change
is annoying for users and forces many users to use 'alias more="more
-e"'. It seems better to force POSIX lovers to use POSIXLY_CORRECT
env. variable and stay backwardly compatible by default.

Addresses: https://github.com/util-linux/util-linux/issues/1703
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2088493
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-06-15 10:03:44 +02:00
Karel Zak
d83a5f8c2b column: improve --table-hide
This option affects list of visible columns, so it's better to apply
it before any other flags, because "-1" placeholder depends on visible
columns. For example:

	echo "A B C D" | column --table --table-maxout --table-right -1 --table-hide 4

needs to hide column #4 (D) and align #3 (C) to the right.

Signed-off-by: Karel Zak <kzak@redhat.com>
2022-06-08 11:31:57 +02:00
Karel Zak
32e4c34f60 column: add -1 placeholder to address last visible column
Addresses: https://github.com/util-linux/util-linux/issues/1700
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-06-08 11:28:02 +02:00
Karel Zak
1dbe96fb64 column: fix "0" placeholder
Addresses: https://github.com/util-linux/util-linux/issues/1700
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-06-08 11:07:58 +02:00
Karel Zak
6be39224f3 column: add --table-maxout
Add option to fill all available space.

Fizes: https://github.com/util-linux/util-linux/issues/1700
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-06-06 11:45:07 +02:00
Karel Zak
5c8f5f171d more: avoid infinite loop on --squeeze
The command 'echo | more -s' ends in infinite loop if exit-on-EOF is
disabled (default now). We need to call more_key_command() to ask for
user's reaction.

Fixes: https://github.com/util-linux/util-linux/issues/1669
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-05-02 12:57:13 +02:00
Karel Zak
e9fe488771 column: fix memory use [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-03-31 09:55:23 +02:00
Karel Zak
8a59ff19ff column: add missing help entry
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-03-30 11:14:31 +02:00
Karel Zak
fd75b96898 column: don't require column name for JSON
The "--table-hide -" hides all unnamed columns, but this does not work
for JSON output. This patch fixes this issue.

Signed-off-by: Karel Zak <kzak@redhat.com>
2022-03-30 11:14:31 +02:00
Karel Zak
b4526713bc column: add --table-column
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-03-30 11:14:31 +02:00
Karel Zak
35d5d655c5 column: implement "--output-width unlimited"
Addresses: https://github.com/util-linux/util-linux/issues/1618
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-03-30 11:14:30 +02:00
Karel Zak
fbfbad0c8f column: (man) add note about default width in non-interactive mode
Fixes: https://github.com/util-linux/util-linux/issues/1618
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-03-07 10:17:08 +01:00
Karel Zak
83bc451acf Merge branch 'manpage-fixes' of https://github.com/mariobl/util-linux
* 'manpage-fixes' of https://github.com/mariobl/util-linux:
  Fix several adoc files as reported by Helge Kreutzmann
  eject.1.adoc: Fix markup
  colors.adoc: format command name bold
  Add missing *.adoc files to Makemodule.am
  Add help-version.adoc to po4a configuration file
  Add new *.adoc files to po4a configuration file
  Fix markup and wording in colors.adoc
2022-02-14 13:16:27 +01:00
Karel Zak
6e908327cb hexdump: call getline() in more robust way
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-02-14 13:00:55 +01:00
Mario Blättermann
bd67ca4480 Fix several adoc files as reported by Helge Kreutzmann 2022-02-13 19:26:07 +01:00
Karel Zak
6fd0e3590a column: use new libsmartcols functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-02-11 12:27:38 +01:00
Karel Zak
6c62faf149 man-pages: consolidate COLORS section
* use man-common/colors.adoc include file

* improve description and add example how to disable colors globally
  or for specific tool

Addresses: https://github.com/util-linux/util-linux/issues/1593
Signed-off-by: Karel Zak <kzak@redhat.com>
2022-02-09 11:59:17 +01:00
Mario Blättermann
2b2d317242 man pages: unify output of --help and --version 2022-02-01 20:49:24 +01:00
Tobias Stoeckmann
8fd1e76631 more: improve zero size handling
Sami Kerola pointed out that /proc contains files with zero size but
content in ec4153cc28.

Eventually fixes for better type handling have been committed with
ba105bb5eb and error handling when "more"
is called with directories in 32a4efc567.

This commit fixes a regression and wrong file size handling:

checkf ends execution prematurely if st.st_size is 0. The idea was to
skip the check_magic call which would otherwise claim that a text file
would not be one, e.g. /proc/self/wchan would fail otherwise. This has
two consequences:

1. The last check in checkf is never true, because if st_size is 0 we
   already left the function (file_size and st_size are both off_t).

Proof of Concept (use a window with less lines than /proc/cpuinfo):

$ echo "hello world" > /tmp/more-poc
$ more /tmp/more-poc /proc/cpuinfo
- Press space to switch to next file
- You see >100% in status line

2. Leaving early does not set the close on exit flag for empty files.

3. Since the last line is never reached, ~(off_t)0 is never set, which
   implies that the check in display_file is never true.

The st.st_size = 0 case is supposed to be special. Simplify this
regression fix by considering ctl->file_size = 0 to be special. This
eleminates the ~(off_t)0 magic, which would be -1.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2022-01-16 22:14:23 +01:00
Karel Zak
c04c380b7a Merge branch 'master' of https://github.com/anya-evergreen/util-linux
* 'master' of https://github.com/anya-evergreen/util-linux:
  Return immediately when quit is seen
2022-01-11 14:17:03 +01:00
Tobias Stoeckmann
dbb2fb3906 Fix wording in comments and documentation
No functional change involved.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2021-12-30 13:49:47 +01:00
Anya
bf3e1c7893
Return immediately when quit is seen
When a quit character is seen, immediately return that command, as it is the correct operation to perform in this case.

A bigger fix is needed here, in that we need to have a *queue* of operations to perform, rather than a single one
2021-12-21 14:26:28 +00:00
Karel Zak
e18f896eb1 more: clear SIGCHLD inherited setting
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-11-15 14:51:52 +01:00
Karel Zak
2ae8b75754 more: fix -e in non-interactive mode
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-10-05 10:53:13 +02:00
Ian Jones
df6b29d3b8 more: POSIX compliance patch preventing exit on EOF without -e
[kzak@redhat.com: - merge all patches to one commit,
                  - improve prompt for non-tty stdin]

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-09-29 14:50:14 +02:00
Mario Blättermann
e674323904 Man pages: Fix end extend formatting 2021-09-21 20:48:11 +02:00
ritikrajdev
e5e0eac42c
more - Bug Resolve - new line separated command execution 2021-09-14 04:27:14 +05:30
Karel Zak
9714331843 column: segmentation fault on invalid unicode input passed to -s option
The function mbs_to_wcs() returns NULL on invalid UTF.

Fixes: https://github.com/karelzak/util-linux/issues/1425
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-08-31 12:31:15 +02:00
Vincent Smeets
9c59b604d3 Erase line before writing the filename 2021-08-20 11:00:33 +02:00
Karel Zak
c67497ce66 more: Calling open without checking return value [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-08-18 10:25:14 +02:00
Karel Zak
042fbf3712 more: use snprintf() rather than sprintf() 2021-07-27 13:31:18 +02:00
Karel Zak
ccedcc55e1 hexdump: do not use atoi()
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-25 11:05:21 +02:00
Karel Zak
0461279ab3 pg: do not use atoi()
Addresses: https://github.com/karelzak/util-linux/issues/1358
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-25 10:24:35 +02:00
Karel Zak
1d5c14ae1a misc: improve string to number conversions
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-24 16:42:53 +02:00
Karel Zak
86f05d3946 more: fix null-pointer dereference
The command allows executing arbitrary shell commands while viewing a file by
entering '!' followed by the command. Entering a command that contains a '%',
'!', or '\' causes a segmentation violation.

The same more(1) function has a problem when not file is specified (cat
/etc/passwd | more) on command line.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1975153
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-23 11:37:31 +02:00
Karel Zak
1293b0f65d misc: consolidate stat() error message
Let's use the same error message everywhere to reduce number of
strings for translators.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-21 12:40:41 +02:00
Karel Zak
17fc8693cd include/c: add drop_permissions(), consolidate UID/GID reset
Fixes: https://github.com/karelzak/util-linux/issues/1354
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-21 12:25:31 +02:00
Karel Zak
2f38ae595b more: add __format__ attribute
Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-18 16:58:38 +02:00
Karel Zak
19f2cebd48 more: fix setuid/setgid order
The rule is pretty simple, always use setgid() before setuid().

Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-06-17 12:21:04 +02:00