mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
(main): Standardize on the diagnostics given when someone gives
too few operands ("missing operand after `xxx'") or
too many operands ("extra operand `xxx'").
Include "quote.h" and/or "error.h" if it wasn't already being included.
This commit is contained in:
1 parent
110be46897
commit
1ce7b61d0e
49 files changed
+202
-121
No files matched your search
+9
-3
@@ -33,6 +33,7 @@
|
||||
#include "long-options.h"
|
||||
#include "dirname.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "basename"
|
||||
@@ -109,10 +110,15 @@ main (int argc, char **argv)
|
||||
++argv;
|
||||
}
|
||||
|
||||
if (argc <= 1 || argc > 3)
|
||||
if (argc < 2)
|
||||
{
|
||||
error (0, 0, (argc <= 1 ? _("too few arguments")
|
||||
: _("too many arguments")));
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (3 < argc)
|
||||
{
|
||||
error (0, 0, _("extra operand %s"), quote (argv[3]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -269,9 +269,12 @@ main (int argc, char **argv)
|
||||
chopt.affect_symlink_referent = (dereference != 0);
|
||||
}
|
||||
|
||||
if (argc - optind + (reference_file ? 1 : 0) <= 1)
|
||||
if (argc - optind < (reference_file ? 1 : 2))
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
if (argc <= optind)
|
||||
error (0, 0, _("missing operand"));
|
||||
else
|
||||
error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -425,7 +425,10 @@ main (int argc, char **argv)
|
||||
|
||||
if (optind >= argc)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
if (modeind == 0 || modeind != argc - 1)
|
||||
error (0, 0, _("missing operand"));
|
||||
else
|
||||
error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -285,9 +285,12 @@ main (int argc, char **argv)
|
||||
chopt.affect_symlink_referent = (dereference != 0);
|
||||
}
|
||||
|
||||
if (argc - optind + (reference_file ? 1 : 0) <= 1)
|
||||
if (argc - optind < (reference_file ? 1 : 2))
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
if (argc <= optind)
|
||||
error (0, 0, _("missing operand"));
|
||||
else
|
||||
error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (argc <= 1)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXIT_FAIL);
|
||||
}
|
||||
|
||||
|
||||
+12
-2
@@ -26,6 +26,7 @@
|
||||
#include "linebuffer.h"
|
||||
#include "error.h"
|
||||
#include "hard-locale.h"
|
||||
#include "quote.h"
|
||||
#include "xmemcoll.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -283,9 +284,18 @@ main (int argc, char **argv)
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (optind + 2 != argc)
|
||||
if (argc - optind < 2)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
if (argc <= optind)
|
||||
error (0, 0, _("missing operand"));
|
||||
else
|
||||
error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (2 < argc - optind)
|
||||
{
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind + 2]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -32,6 +32,7 @@
|
||||
#include "error.h"
|
||||
#include "inttostr.h"
|
||||
#include "safe-read.h"
|
||||
#include "quote.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
#ifndef SA_NOCLDSTOP
|
||||
@@ -1374,7 +1375,10 @@ main (int argc, char **argv)
|
||||
|
||||
if (argc - optind < 2)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
if (argc <= optind)
|
||||
error (0, 0, _("missing operand"));
|
||||
else
|
||||
error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -373,8 +373,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (n_args > 1)
|
||||
{
|
||||
error (0, 0, _("too many non-option arguments: %s%s"),
|
||||
argv[optind + 1], n_args == 2 ? "" : " ...");
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+6
-10
@@ -462,17 +462,13 @@ to select a shell syntax are mutually exclusive"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (print_database && argc > 0)
|
||||
if (!print_database < argc)
|
||||
{
|
||||
error (0, 0,
|
||||
_("no FILE arguments may be used with the option to output\n\
|
||||
dircolors' internal database"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!print_database && argc > 1)
|
||||
{
|
||||
error (0, 0, _("too many arguments"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[!print_database]));
|
||||
if (print_database)
|
||||
fprintf (stderr, "%s\n",
|
||||
_("File operands cannot be combined with "
|
||||
"--print-database (-p)."));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+9
-3
@@ -25,6 +25,7 @@
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
#include "dirname.h"
|
||||
#include "quote.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "dirname"
|
||||
@@ -84,10 +85,15 @@ main (int argc, char **argv)
|
||||
++argv;
|
||||
}
|
||||
|
||||
if (argc != 2)
|
||||
if (argc < 2)
|
||||
{
|
||||
error (0, 0, argc < 2 ? _("too few arguments")
|
||||
: _("too many arguments"));
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (2 < argc)
|
||||
{
|
||||
error (0, 0, _("extra operand %s"), quote (argv[2]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
@@ -735,9 +735,12 @@ main (int argc, char **argv)
|
||||
/* When using --files0-from=F, you may not specify any files
|
||||
on the command-line. */
|
||||
if (optind < argc)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("%s: you may not specify command-line arguments with\
|
||||
--files0-from"), quotearg_colon (argv[optind]));
|
||||
{
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind]));
|
||||
fprintf (stderr, "%s\n",
|
||||
_("File operands cannot be combined with --files0-from."));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
istream = (STREQ (files_from, "-") ? stdin : fopen (files_from, "r"));
|
||||
if (istream == NULL)
|
||||
|
||||
+1
-1
@@ -196,7 +196,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (argc <= 1)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXPR_INVALID);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "hostid"
|
||||
@@ -83,7 +84,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
error (0, 0, _("too many arguments"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[1]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -24,6 +24,7 @@
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "hostname"
|
||||
@@ -131,7 +132,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
error (0, 0, _("too many arguments"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[2]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "id"
|
||||
@@ -166,7 +167,10 @@ main (int argc, char **argv)
|
||||
_("cannot print only names or real IDs in default format"));
|
||||
|
||||
if (argc - optind > 1)
|
||||
usage (EXIT_FAILURE);
|
||||
{
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (argc - optind == 1)
|
||||
{
|
||||
|
||||
+4
-1
@@ -283,7 +283,10 @@ main (int argc, char **argv)
|
||||
|
||||
if (argc <= optind || (n_files == 1 && !dir_arg))
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
if (argc <= optind)
|
||||
error (0, 0, _("missing operand"));
|
||||
else
|
||||
error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -85,13 +85,16 @@ main (int argc, char **argv)
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
if (argc < 2)
|
||||
error (0, 0, _("missing operand"));
|
||||
else
|
||||
error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (3 < argc)
|
||||
{
|
||||
error (0, 0, _("too many arguments"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[3]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
@@ -493,7 +493,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (argc <= optind)
|
||||
{
|
||||
error (0, 0, _("missing file argument"));
|
||||
error (0, 0, _("missing file operand"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "quote.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "logname"
|
||||
@@ -88,7 +89,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
error (0, 0, _("too many arguments"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+7
-3
@@ -30,6 +30,7 @@
|
||||
#include "checksum.h"
|
||||
#include "getline.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME (algorithm == ALG_MD5 ? "md5sum" : "sha1sum")
|
||||
@@ -644,7 +645,9 @@ verifying checksums"));
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
error (0, 0, _("no files may be specified when using --string"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind]));
|
||||
fprintf (stderr, "%s\n",
|
||||
_("File operands cannot be combined with --string."));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
for (i = 0; i < n_strings; ++i)
|
||||
@@ -665,8 +668,9 @@ verifying checksums"));
|
||||
{
|
||||
if (optind + 1 < argc)
|
||||
{
|
||||
error (0, 0,
|
||||
_("only one argument may be specified when using --check"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
|
||||
fprintf (stderr, "%s\n",
|
||||
_("Only one operand may be specified when using --check."));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -122,7 +122,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+20
-22
@@ -91,6 +91,7 @@ main (int argc, char **argv)
|
||||
struct mode_change *change;
|
||||
const char *specified_mode;
|
||||
int optc;
|
||||
int expected_operands;
|
||||
mode_t node_type;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
@@ -131,16 +132,27 @@ main (int argc, char **argv)
|
||||
newmode = mode_adjust (newmode, change);
|
||||
}
|
||||
|
||||
if (argc - optind != 2 && argc - optind != 4)
|
||||
expected_operands = (argv[optind + 1][0] == 'p' ? 2 : 4);
|
||||
|
||||
if (argc - optind < expected_operands)
|
||||
{
|
||||
const char *msg;
|
||||
if (argc - optind < 2)
|
||||
msg = _("too few arguments");
|
||||
else if (argc - optind > 4)
|
||||
msg = _("too many arguments");
|
||||
if (argc <= optind)
|
||||
error (0, 0, _("missing operand"));
|
||||
else
|
||||
msg = _("wrong number of arguments");
|
||||
error (0, 0, "%s", msg);
|
||||
error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
|
||||
if (expected_operands == 4 && argc - optind == 2)
|
||||
fprintf (stderr, "%s\n",
|
||||
_("Special files require major and minor device numbers."));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (expected_operands < argc - optind)
|
||||
{
|
||||
error (0, 0, _("extra operand %s"),
|
||||
quote (argv[optind + expected_operands]));
|
||||
if (expected_operands == 2 && argc - optind == 4)
|
||||
fprintf (stderr,
|
||||
_("Fifos do not have major and minor device numbers."));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -167,14 +179,6 @@ main (int argc, char **argv)
|
||||
goto block_or_character;
|
||||
|
||||
block_or_character:
|
||||
if (argc - optind != 4)
|
||||
{
|
||||
error (0, 0, _("\
|
||||
when creating special files, major and minor device\n\
|
||||
numbers must be specified"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
{
|
||||
char const *s_major = argv[optind + 2];
|
||||
char const *s_minor = argv[optind + 3];
|
||||
@@ -206,12 +210,6 @@ numbers must be specified"));
|
||||
#ifndef S_ISFIFO
|
||||
error (EXIT_FAILURE, 0, _("fifo files not supported"));
|
||||
#else
|
||||
if (argc - optind != 2)
|
||||
{
|
||||
error (0, 0, _("\
|
||||
major and minor device numbers may not be specified for fifo files"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
if (mkfifo (argv[optind], newmode))
|
||||
error (EXIT_FAILURE, errno, "%s", quote (argv[optind]));
|
||||
#endif
|
||||
|
||||
@@ -457,7 +457,11 @@ main (int argc, char **argv)
|
||||
|
||||
if (n_files == 0 || (n_files == 1 && !target_directory_specified))
|
||||
{
|
||||
error (0, 0, _("missing file argument"));
|
||||
if (n_files == 0)
|
||||
error (0, 0, _("missing file operand"));
|
||||
else
|
||||
error (0, 0, _("missing file operand after %s"),
|
||||
quote (argv[argc - 1]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (argc <= 1)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (NOHUP_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "posixver.h"
|
||||
#include "quote.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -1873,8 +1874,9 @@ it must be one character from [doxn]"),
|
||||
}
|
||||
else if (n_files > 3)
|
||||
{
|
||||
error (0, 0,
|
||||
_("compatibility mode supports at most three arguments"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind + 3]));
|
||||
fprintf (stderr, "%s\n",
|
||||
_("Compatibility mode supports at most three operands."));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -186,7 +186,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "argmatch.h"
|
||||
#include "diacrit.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
#include "quotearg.h"
|
||||
#include "regex.h"
|
||||
#include "xstrtol.h"
|
||||
@@ -2162,7 +2163,10 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n"),
|
||||
/* Diagnose any other argument as an error. */
|
||||
|
||||
if (optind < argc)
|
||||
usage (EXIT_FAILURE);
|
||||
{
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
/* If the output format has not been explicitly selected, choose dumb
|
||||
|
||||
+2
-2
@@ -125,7 +125,7 @@ main (int argc, char *const argv[])
|
||||
|
||||
if (optind >= argc)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ main (int argc, char *const argv[])
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
error (0, 0, _("too many arguments"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ main (int argc, char **argv)
|
||||
exit (EXIT_SUCCESS);
|
||||
else
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -205,7 +205,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "system.h"
|
||||
#include "c-strtod.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
#include "xstrtol.h"
|
||||
#include "xstrtod.h"
|
||||
|
||||
@@ -371,13 +372,13 @@ main (int argc, char **argv)
|
||||
|
||||
if (argc - optind < 1)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (3 < argc - optind)
|
||||
{
|
||||
error (0, 0, _("too many arguments"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind + 3]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -96,7 +96,10 @@ main (int argc, char **argv)
|
||||
|
||||
if (argc <= 2)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
if (argc < 2)
|
||||
error (0, 0, _("missing operand"));
|
||||
else
|
||||
error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
|
||||
usage (SETUIDGID_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1685,7 +1685,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (n_files == 0)
|
||||
{
|
||||
error (0, 0, _("missing file argument"));
|
||||
error (0, 0, _("missing file operand"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -34,6 +34,7 @@
|
||||
#include "long-options.h"
|
||||
#include "physmem.h"
|
||||
#include "posixver.h"
|
||||
#include "quote.h"
|
||||
#include "stdio-safer.h"
|
||||
#include "xmemcoll.h"
|
||||
#include "xstrtol.h"
|
||||
@@ -2511,8 +2512,11 @@ main (int argc, char **argv)
|
||||
if (checkonly)
|
||||
{
|
||||
if (nfiles > 1)
|
||||
error (SORT_FAILURE, 0, _("extra operand `%s' not allowed with -c"),
|
||||
files[1]);
|
||||
{
|
||||
error (0, 0, _("extra operand %s not allowed with -c"),
|
||||
quote (files[1]));
|
||||
usage (SORT_FAILURE);
|
||||
}
|
||||
|
||||
/* POSIX requires that sort return 1 IFF invoked with -c and the
|
||||
input is not properly sorted. */
|
||||
|
||||
+2
-1
@@ -35,6 +35,7 @@
|
||||
#include "full-write.h"
|
||||
#include "inttostr.h"
|
||||
#include "posixver.h"
|
||||
#include "quote.h"
|
||||
#include "safe-read.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
@@ -532,7 +533,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
error (0, 0, _("too many arguments"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -821,7 +821,7 @@ main (int argc, char *argv[])
|
||||
|
||||
if (argc == optind)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -409,7 +409,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (optind == argc)
|
||||
{
|
||||
error (0, 0, _("file arguments missing"));
|
||||
error (0, 0, _("missing file operand"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
#include "safe-read.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
@@ -1671,6 +1672,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
int non_option_args;
|
||||
int min_operands;
|
||||
int max_operands;
|
||||
struct Spec_list buf1, buf2;
|
||||
struct Spec_list *s1 = &buf1;
|
||||
struct Spec_list *s2 = &buf2;
|
||||
@@ -1719,35 +1722,34 @@ main (int argc, char **argv)
|
||||
|
||||
non_option_args = argc - optind;
|
||||
translating = (non_option_args == 2 && !delete);
|
||||
min_operands = 1 + (delete == squeeze_repeats);
|
||||
max_operands = 1 + (delete <= squeeze_repeats);
|
||||
|
||||
/* Change this test if it is valid to give tr no options and
|
||||
no args at all. POSIX doesn't specifically say anything
|
||||
either way, but it looks like they implied it's invalid
|
||||
by omission. If you want to make tr do a slow imitation
|
||||
of `cat' use `tr a a'. */
|
||||
if (non_option_args > 2)
|
||||
if (non_option_args < min_operands)
|
||||
{
|
||||
error (0, 0, _("too many arguments"));
|
||||
if (non_option_args == 0)
|
||||
error (0, 0, _("missing operand"));
|
||||
else
|
||||
{
|
||||
error (0, 0, _("missing operand after %s"), quote (argv[argc - 1]));
|
||||
fprintf (stderr, "%s\n",
|
||||
_(squeeze_repeats
|
||||
? ("Two strings must be given when "
|
||||
"both deleting and squeezing repeats.")
|
||||
: "Two strings must be given when translating."));
|
||||
}
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!delete && !squeeze_repeats && non_option_args != 2)
|
||||
error (EXIT_FAILURE, 0, _("two strings must be given when translating"));
|
||||
|
||||
if (delete && squeeze_repeats && non_option_args != 2)
|
||||
error (EXIT_FAILURE, 0, _("two strings must be given when both \
|
||||
deleting and squeezing repeats"));
|
||||
|
||||
/* If --delete is given without --squeeze-repeats, then
|
||||
only one string argument may be specified. */
|
||||
if ((delete && !squeeze_repeats) && non_option_args != 1)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("only one string may be given when deleting \
|
||||
without squeezing repeats"));
|
||||
|
||||
if (squeeze_repeats && non_option_args == 0)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("at least one string must be given when squeezing repeats"));
|
||||
if (max_operands < non_option_args)
|
||||
{
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind + max_operands]));
|
||||
if (non_option_args == 2)
|
||||
fprintf (stderr, "%s\n",
|
||||
_("Only one string may be given when "
|
||||
"deleting without squeezing repeats."));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
spec_init (s1);
|
||||
if (!parse_str (argv[optind], s1))
|
||||
|
||||
+2
-1
@@ -31,6 +31,7 @@
|
||||
#include "system.h"
|
||||
#include "long-options.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
#include "readtokens.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -573,7 +574,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (1 < argc - optind)
|
||||
{
|
||||
error (0, 0, _("only one argument may be specified"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
|
||||
/* Exit statuses. */
|
||||
enum
|
||||
@@ -116,7 +117,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
error (0, 0, _("ignoring all arguments"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind]));
|
||||
|
||||
tty = ttyname (0);
|
||||
if (!silent)
|
||||
|
||||
+2
-1
@@ -46,6 +46,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "uname"
|
||||
@@ -212,7 +213,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (argc != optind)
|
||||
{
|
||||
error (0, 0, _("too many arguments"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -29,6 +29,7 @@
|
||||
#include "error.h"
|
||||
#include "hard-locale.h"
|
||||
#include "posixver.h"
|
||||
#include "quote.h"
|
||||
#include "xmemcoll.h"
|
||||
#include "xstrtol.h"
|
||||
#include "memcasecmp.h"
|
||||
@@ -435,7 +436,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
if (nfiles == 2)
|
||||
{
|
||||
error (0, 0, _("extra operand `%s'"), argv[optind]);
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
file[nfiles++] = argv[optind++];
|
||||
@@ -452,7 +453,7 @@ main (int argc, char **argv)
|
||||
skip_chars = size;
|
||||
else if (nfiles == 2)
|
||||
{
|
||||
error (0, 0, _("extra operand `%s'"), optarg);
|
||||
error (0, 0, _("extra operand %s"), quote (optarg));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
else
|
||||
|
||||
+2
-2
@@ -84,13 +84,13 @@ main (int argc, char **argv)
|
||||
|
||||
if (argc < 2)
|
||||
{
|
||||
error (0, 0, _("too few arguments"));
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (2 < argc)
|
||||
{
|
||||
error (0, 0, _("too many arguments"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[2]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "quote.h"
|
||||
#include "readutmp.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -244,7 +245,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
default: /* lose */
|
||||
error (0, 0, _("too many arguments"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -26,6 +26,7 @@
|
||||
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "quote.h"
|
||||
#include "readutmp.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -168,7 +169,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
default: /* lose */
|
||||
error (0, 0, _("too many arguments"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "readutmp.h"
|
||||
#include "error.h"
|
||||
#include "inttostr.h"
|
||||
#include "quote.h"
|
||||
#include "vasprintf.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -812,7 +813,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
default: /* lose */
|
||||
error (0, 0, _("too many arguments"));
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind + 2]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
+6
-1
@@ -27,7 +27,9 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "long-options.h"
|
||||
#include "quote.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "whoami"
|
||||
@@ -94,7 +96,10 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (optind != argc)
|
||||
usage (EXIT_FAILURE);
|
||||
{
|
||||
error (0, 0, _("extra operand %s"), quote (argv[optind]));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
uid = geteuid ();
|
||||
pw = getpwuid (uid);
|
||||
|
||||
Reference in new issue
Block a user