Commit Graph

77 Commits

Author SHA1 Message Date
Rosen Penev 042f62dfc5
[clang-tidy] do not use else after return
Found with readability-else-after-return

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:20:59 -07:00
Rosen Penev bd89499e07
[clang-tidy] do not return in void functions
Found with readability-redundant-control-flow

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-19 14:03:21 -07:00
Elliott Mitchell 2bb3aa36b2 cleanup: Remove some spurious spaces
Sorry detail-oriented people tend to wipe these out if they notice them.
Add in automated tools and lots of excess end-of-line spaces get wiped
out.

Addresses: https://github.com/karelzak/util-linux/pull/849
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-01 13:01:43 +02:00
Karel Zak bc6439ba32 setterm: cleanup usage() and man page
usage:
 * use --option[=<argument>] to make it obvious that '=' is required
 * don't use [ ] for required arguments
 * add separators to make it more readable

man page
 * use --option=[<argument>] for optional arguments in man page
 * don't use \fI or \fB for keywords based arguments (on|off|default ...)
 * use the same style in all man page

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-10 12:14:25 +02:00
Karel Zak 36ce5ebaf4 setterm: fix --clear
* make argument optional as in the original version
* fix typo (reset -> rest)

Addresses: https://github.com/karelzak/util-linux/issues/861
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-10 11:12:38 +02:00
Karel Zak 2c308875a7 misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 15:14:13 +02:00
Jakub Wilk f28985ffc3 setterm: fix --hbcolor description
--hbcolor is for half-bright characters, which is sort of opposite of
bold.

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2019-03-08 21:27:59 +01:00
Jakub Wilk bec23f0bf2 setterm: update comments about -ulcolor/-hbcolor syntax
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2019-03-07 22:11:46 +01:00
Jakub Wilk 3d886e86f6 setterm: fix bright colors for --ulcolor/--hbcolor
The "bright" keyword was parsed, but it didn't actually affect the color
that was set.

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2019-03-07 22:11:46 +01:00
Jakub Wilk c1b4cf105d setterm: disallow "default" for --ulcolor/--hbcolor
Passing "default" to --ulcolor or --hbcolor worked, but it set the color to
bright red. This was not a documented syntax, so let's forbid it.

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2019-03-07 22:11:38 +01:00
Karel Zak df3bc05a7f setterm: fix compiler warnings [-Wcast-qual]
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-23 11:45:15 +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
Ruediger Meier 6e1eda6f22 misc: never use usage(stderr)
Here we fix all cases where we have usage(FILE*)
functions.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Karel Zak 3947ca4ca9 build-sys: ncurses headers cleanup
* assume ncursesw headers in ncursesw/ directory only
* prefer long paths, <term.h> and <ncurses.h> should be last
  possibility
* fix typos

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-31 11:01:46 +02:00
Karel Zak 2ac1bc84d7 text-utils: use proper paths to term.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-05-30 17:15:37 +02:00
Sami Kerola e9f62f3881 setterm: fix bitfield warning [smatch]
term-utils/setterm.c:179:27: warning: dubious bitfield without explicit
`signed' or `unsigned'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-28 14:38:22 +01:00
Sami Kerola 8791804065 misc: do not use plain 0 as NULL [smatch scan]
text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer

Since many 'struct option' has used zero as NULL make them more readable in
same go by reindenting, and using named argument requirements.

Reference: https://lwn.net/Articles/93577/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Sami Kerola 5d79599951
setterm: add --resize option
Reset terminal size by assessing maximum row and column.  This is useful
when actual geometry and kernel terminal driver are not in sync.

Addresses: http://bugs.debian.org/835636
Based-on-work-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-12-29 10:56:15 +00: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
Ruediger Meier 223939d95b misc: spelling, always use "cannot" instead of "can not"
Just to be consistent ...

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-11-30 14:56:50 +01:00
Sami Kerola ef4d11d57e
setterm: fix declarations shadowing variables in the global scope [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sami Kerola 74ce680a3e
misc: simplify if clauses [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sebastian Rasmussen 9e93004171 misc: Fix various typos
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Sami Kerola c8a6f83e85 setterm: remove unnecessary translation string
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-05-09 12:57:01 +02:00
Karel Zak 98297e65a1 setterm: de-duplicate color option string parsing
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-05-09 12:35:41 +02:00
Karel Zak 2660801513 setterm: remove dead code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-05 11:51:04 +02:00
Karel Zak 30b294c491 lib/strutils: extend parse_switch() to accept more options
* allow to specify more 0|1 pairs
* allow to specify error message

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-24 12:04:22 +01:00
Sami Kerola e5cf147655 lib/strutils: move parse_switch() from setterm(1) to library
To allow sharing the code with other utilities.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-24 11:33:31 +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
Sami Kerola d8c1fc7ac4 setterm: fix dubious one-bit signed bitfield [smatch scan]
term-utils/setterm.c:165:24: error: dubious one-bit signed bitfield

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-20 14:07:19 +02:00
Sami Kerola 4636f0613d setterm: remove unnecessary variable
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-13 17:27:10 +01:00
Benno Schulenberg d276d99572 setterm: improve formatting and wording of usage text
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>
2014-06-30 10:21:11 +02:00
Sami Kerola 5edc8dbc33 setterm: add usage() descriptions
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-26 16:35:59 +01:00
Karel Zak 2832032772 setterm: fix 'bright' in usage, remove unnecessary error message
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-20 11:56:43 +02:00
Sami Kerola fbb08864cb setterm: remove ulcolor and hbcolor duplicates
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:58:14 +01:00
Sami Kerola 7a20c8a188 setterm: add set_blanking() action
This make over long perform_sequence() function a little bit shorter.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:24 +01:00
Sami Kerola 11f69359fa setterm: mark some options to be exclusive with each other
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:24 +01:00
Sami Kerola 78dd23cbf5 setterm: various visual terminal effects are not console specific
Setting colors, making line not to wrap, and so on can be attempted in
other than consoles.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:23 +01:00
Sami Kerola cda2b5b951 setterm: improve error messages
Reuse messages to make translation work easier.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:23 +01:00
Sami Kerola da27df2553 setterm: tell user when options does not effect
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:23 +01:00
Sami Kerola 16279cc2b4 setterm: improve perform_sequence() coding style
Delete pointless braces, new lines, and add spacing between operators.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:23 +01:00
Sami Kerola 253e5e7161 setterm: correct usage() bright color argument
This has been wrong since commit 2dc8716.  The bright is a prefix
attribute to other colors.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:54:17 +01:00
Sami Kerola 917465831f setterm: make -msglevel 0 to work as is did earlier
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>
2014-05-19 22:45:39 +01:00
Sami Kerola 609d48534a setterm: remove devfs and /dev/vcsa0 support
The devfs files /dev/vcc/a* does not need to be supported, and vcsa0 has
not existed in years if ever.

Reference: http://lwn.net/Articles/65197/
Reference: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/devices.txt?id=14186fea0cb06bc43181ce239efe0df6f1af260a#n260
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:45:38 +01:00
Sami Kerola 341566ff45 setterm: clean up screendump()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:45:38 +01:00
Sami Kerola dcc2fe2903 setterm: add init_terminal() to make main() shorter
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:45:38 +01:00
Sami Kerola d87d20b0fa setterm: add option control structure
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-19 22:45:38 +01:00
Sami Kerola 43f68f8fea setterm: remove usage comment segment
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>
2014-05-19 22:45:38 +01:00
Sami Kerola c591be873b setterm: move show_tabs() and screendump() functions
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>
2014-05-19 22:45:37 +01:00