Commit Graph

40 Commits

Author SHA1 Message Date
Karel Zak 390ba85c78 renice: fix arguments description in --help
The --{pid,pgrp,user} options does not have arguments.

Reported-by: Stephane Chazelas <stephane.chazelas@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-08 11:32:18 +01:00
Karel Zak cb99f4ea79 renice: fix --help text
The option [-n] in the code has no any meaning and the value is used
as priority, not incrementally.

Reported-by: Stephane Chazelas <stephane.chazelas@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-08 11:22:57 +01:00
Karel Zak 9f74aa07d4 renice: make code more readable for static analyzer [coverity scan]
It seems coverity and clag have no clue about relation between argv[]
and argc. Let's make code more readable for them...

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-05-28 12:19:23 +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
Yuri Chornoivan e2215a8545 Fix minor typo: priorty -> priority 2017-12-31 13:07:43 +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 b1a294c448 misc: introduce print_usage_help_options()
Consolidate --help and --version descriptions. We are
now able to align them to the other options.

We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-27 12:26:19 +02:00
Ruediger Meier 9325dbfd20 misc: cleanup and fix --unknownopt issues
Fixed checkusage.sh warnings:

  rtcwake: --unknownopt, non-empty stdout

  rtcwake: --unknownopt, stderr too long: 21
  blockdev: --unknownopt, stderr too long: 28
  lsipc: --unknownopt, stderr too long: 77
  pg: --unknownopt, stderr too long: 23
  renice: --unknownopt, stderr too long: 18
  sulogin: --unknownopt, stderr too long: 17
  write: --unknownopt, stderr too long: 12

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02: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
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
Benno Schulenberg 09638694d4 textual: use angular brackets around each individual argument
In usage texts each word that is an argument should be marked
separately with angular brackets.  Also add a translator comment.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-10-01 09:37:02 +02:00
Sami Kerola 94b1623be3 renice: reorder usage() option descriptions
Make the Usage: and Options: sections to be in same order, which I found
to be quicker to use than alphabetical order.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:13 +01:00
Sami Kerola ce4030e484 rename: add getpriority() message lookup table
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:13 +01:00
Sami Kerola 80ca9e2039 renice: fix numeric uid argument parsing
The following was inconflict with what usage() tells are valid option
arguments.

$ renice 1 -u 1000
renice: unknown user 1000
$ id
uid=1000(kerolasa) ...

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:13 +01:00
Sami Kerola 00b490f002 renice: avoid having same lines of code twice
Add getprio() function to avoid duplication of a simple task.

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:13 +01:00
Sami Kerola 0bb01bb0b7 renice: disallow --priority <arg> without pid argument
Earlier a lonely priority with an argument but without pid resulted to no
action and success, when the invocation should have failed.

$ renice --priority 42 ; echo $?
0

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:12 +01:00
Sami Kerola 6dcc066f3b rename: use usage and version print out macros
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:12 +01:00
Sami Kerola 5ebcab664e renice: reorder functions to avoid need of function prototype
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:12 +01:00
Sami Kerola 665b3c8572 renice: exit with non-zero value when arguments cause warnings
This commit also fixes potential error counter wrap, which theoretically
could make command to exit with a success when it internally failed just
correct amount of times.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-07-01 11:07:19 +02: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
Benno Schulenberg 5cc224f552 renice: accept also -V for --version, and document it
Also improve the man page.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-01-25 11:47:33 +01:00
Benno Schulenberg ae3ca2aacc renice: correct the usage synopsis, and improve help text
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-01-25 11:47:30 +01:00
Sami Kerola efb8854f4c sys-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:49:40 +02:00
Karel Zak ae1ae49e78 renice: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-16 13:20:54 +02:00
Fabian Groffen eb76ca98b0 build-sys: provide alternatives for err, errx, warn and warnx
Solaris lacks err, errx, warn and warnx.  This also means the err.h header
doesn't exist.  Removed err.h include from all files, and included err.h from
c.h instead if it exists, otherwise alternatives are provided.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-02-14 17:45:24 +01:00
Karel Zak abafd68667 fix __noreturn__ usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-12-10 16:47:18 +01:00
Francesco Cosoleto 8aa5046647 renice: improve messages specifying what ID is referring to
Hello,

On 30/11/2010 13:01, Karel Zak wrote:

> Unfortunately, translators don't like this kind of strings where any
> translatable substring is inserted to the normal sentence. It would be
> better to use something like:
>
>   "%d (%s): failed to set priority", who, idtype
>
>   "%s: %d: failed to set priority", idtype, who
>
> or so...

or "failed to set priority for %d (%s)"?

From 536eb11f873f2c887e075a37ffb3c971cac258d5 Mon Sep 17 00:00:00 2001
From: Francesco Cosoleto <cosoleto@gmail.com>
Date: Mon, 6 Dec 2010 01:23:10 +0100
Subject: [PATCH] renice: improve messages specifying what ID is referring to

This version makes more clear the printed message specially when the
--user option is used.

Old version:
   $ renice 19 10 -u fra -g 1
renice: 10: setpriority: Operation not permitted
renice: 1000: setpriority: Operation not permitted
renice: 1: setpriority: Operation not permitted

   $ renice 19 -u fra
1000: old priority 0, new priority 19

New version:
   $ renice 19 10 -u fra -g 1
renice: failed to set priority for 10 (process ID): Operation not permitted
renice: failed to set priority for 1000 (user ID): Operation not permitted
renice: failed to set priority for 1 (process group ID): Operation not permitted

   $ renice 19 -u fra
1000 (user ID) old priority 0, new priority 19

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2010-12-09 23:07:41 +01:00
Karel Zak 296351b0f1 renice: rewrite usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-30 12:46:06 +01:00
Francesco Cosoleto 40cebc2d6f renice: reverse %s position in error messages
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2010-11-30 12:28:17 +01:00
Francesco Cosoleto 83fa126b93 renice: remove hardcoded program name using warn() and warnx()
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2010-11-30 12:28:17 +01:00
Francesco Cosoleto 22e0d3ec97 renice: make some functions static 2010-11-30 12:28:17 +01:00
Karel Zak 7cfbafda9c renice: add -n option for compatibility with POSIX
The -n option is required by POSIX.1-200x.

Signed-off-by: Karel Zak <kzak@redhat.com>
2009-03-09 21:09:50 +01:00
LaMont Jones 628cab7cde renice: detect errors in arguments, add -v, -h and long options
* renice was using atoi(), which does no error detection, meaning
   that: "renice +20 blah" was accepted as valid.

 * add -h | --help

 * add -v | --version

 * add long options for -p, -u and -g

 * cleanup coding style

Addresses-Debian-Bug: #385245
Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: LaMont Jones <lamont@debian.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-01-29 15:31:47 +01:00
Karel Zak e8f2641919 Imported from util-linux-2.11m tarball. 2006-12-07 00:25:49 +01:00
Karel Zak c07ebfa1e0 Imported from util-linux-2.11b tarball. 2006-12-07 00:25:46 +01:00
Karel Zak 66ee8158b6 Imported from util-linux-2.10s tarball. 2006-12-07 00:25:44 +01:00
Karel Zak 7eda085c41 Imported from util-linux-2.9v tarball. 2006-12-07 00:25:39 +01:00
Karel Zak 2b6fc908bc Imported from util-linux-2.8 tarball. 2006-12-07 00:25:35 +01:00
Karel Zak fd6b7a7ffc Imported from util-linux-2.7.1 tarball. 2006-12-07 00:25:34 +01:00
Karel Zak 6dbe3af945 Imported from util-linux-2.2 tarball. 2006-12-07 00:25:32 +01:00