diff options
author | Jim Meyering <jim@meyering.net> | 1994-10-08 00:34:54 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1994-10-08 00:34:54 +0000 |
commit | 5a31cea3d4d2f9293fdb794b950952ae89753883 (patch) | |
tree | 355262abdbc7f5680d81be44fb79cab11de51cfa | |
parent | 0eb406c7e6c83e9c925f0e42b0692dba95aeff79 (diff) | |
download | coreutils-5a31cea3d4d2f9293fdb794b950952ae89753883.tar.xz |
.
-rw-r--r-- | src/chgrp.c | 7 | ||||
-rw-r--r-- | src/chmod.c | 5 | ||||
-rw-r--r-- | src/chown.c | 5 | ||||
-rw-r--r-- | src/install.c | 13 | ||||
-rw-r--r-- | src/mkdir.c | 5 | ||||
-rw-r--r-- | src/mkfifo.c | 5 | ||||
-rw-r--r-- | src/mknod.c | 32 | ||||
-rw-r--r-- | src/rm.c | 5 | ||||
-rw-r--r-- | src/rmdir.c | 5 | ||||
-rw-r--r-- | src/sync.c | 1 |
10 files changed, 67 insertions, 16 deletions
diff --git a/src/chgrp.c b/src/chgrp.c index 84e6b4fc8..71d0f8dec 100644 --- a/src/chgrp.c +++ b/src/chgrp.c @@ -137,8 +137,11 @@ main (argc, argv) if (show_help) usage (0); - if (optind >= argc - 1) - usage (1); + if (argc - optind <= 1) + { + error (0, 0, "too few arguments"); + usage (1); + } parse_group (argv[optind++], &group); diff --git a/src/chmod.c b/src/chmod.c index 17495cb6b..6285ca9c7 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -157,7 +157,10 @@ main (argc, argv) modeind = optind++; if (optind >= argc) - usage (1); + { + error (0, 0, "too few arguments"); + usage (1); + } changes = mode_compile (argv[modeind], MODE_MASK_EQUALS | MODE_MASK_PLUS | MODE_MASK_MINUS); diff --git a/src/chown.c b/src/chown.c index 3eac74a06..6177a7268 100644 --- a/src/chown.c +++ b/src/chown.c @@ -151,7 +151,10 @@ main (argc, argv) usage (0); if (optind >= argc - 1) - usage (1); + { + error (0, 0, "too few arguments"); + usage (1); + } e = parse_user_spec (argv[optind], &user, &group, &username, &groupname); if (e) diff --git a/src/install.c b/src/install.c index fc880e03e..75958f1bd 100644 --- a/src/install.c +++ b/src/install.c @@ -211,10 +211,15 @@ main (argc, argv) usage (0); /* Check for invalid combinations of arguments. */ - if ((dir_arg && strip_files) - || (optind == argc) - || (optind == argc - 1 && !dir_arg)) - usage (1); + if (dir_arg && strip_files) + error (1, 0, + "the strip option may not be used when installing a directory"); + + if (optind == argc || (optind == argc - 1 && !dir_arg)) + { + error (0, 0, "too few arguments"); + usage (1); + } if (symbolic_mode) { diff --git a/src/mkdir.c b/src/mkdir.c index 5a6030490..0bbe34441 100644 --- a/src/mkdir.c +++ b/src/mkdir.c @@ -103,7 +103,10 @@ main (argc, argv) usage (0); if (optind == argc) - usage (1); + { + error (0, 0, "too few arguments"); + usage (1); + } newmode = 0777 & ~umask (0); parent_mode = newmode | 0300; /* u+wx */ diff --git a/src/mkfifo.c b/src/mkfifo.c index 0c9972334..1e6d50070 100644 --- a/src/mkfifo.c +++ b/src/mkfifo.c @@ -92,7 +92,10 @@ main (argc, argv) usage (0); if (optind == argc) - usage (1); + { + error (0, 0, "too few arguments"); + usage (1); + } newmode = 0666 & ~umask (0); if (symbolic_mode) diff --git a/src/mknod.c b/src/mknod.c index 957e11a74..8d7ace86c 100644 --- a/src/mknod.c +++ b/src/mknod.c @@ -104,7 +104,17 @@ main (argc, argv) } if (argc - optind != 2 && argc - optind != 4) - usage (1); + { + const char *msg; + if (argc - optind < 2) + msg = "too few arguments"; + else if (argc - optind > 4) + msg = "too many arguments"; + else + msg = "wrong number of arguments"; + error (0, 0, msg); + usage (1); + } /* Only check the first character, to allow mnemonic usage like `mknod /dev/rst0 character 18 0'. */ @@ -116,7 +126,12 @@ main (argc, argv) error (4, 0, "block special files not supported"); #else if (argc - optind != 4) - usage (1); + { + error (0, 0, "\ +when creating block special files, major and minor device\n\ +numbers must be specified"); + usage (1); + } if (mknod (argv[optind], newmode | S_IFBLK, makedev (atoi (argv[optind + 2]), atoi (argv[optind + 3])))) error (1, errno, "%s", argv[optind]); @@ -129,7 +144,12 @@ main (argc, argv) error (4, 0, "character special files not supported"); #else if (argc - optind != 4) - usage (1); + { + error (0, 0, "\ +when creating character special files, major and minor device\n\ +numbers must be specified"); + usage (1); + } if (mknod (argv[optind], newmode | S_IFCHR, makedev (atoi (argv[optind + 2]), atoi (argv[optind + 3])))) error (1, errno, "%s", argv[optind]); @@ -141,7 +161,11 @@ main (argc, argv) error (4, 0, "fifo files not supported"); #else if (argc - optind != 2) - usage (1); + { + error (0, 0, "\ +major and minor device numbers may not be specified for fifo files"); + usage (1); + } if (mkfifo (argv[optind], newmode)) error (1, errno, "%s", argv[optind]); #endif @@ -153,7 +153,10 @@ main (argc, argv) if (ignore_missing_files) exit (0); else - usage (1); + { + error (0, 0, "too few arguments"); + usage (1); + } } stdin_tty = isatty (STDIN_FILENO); diff --git a/src/rmdir.c b/src/rmdir.c index ba8c15d3b..18f55d81f 100644 --- a/src/rmdir.c +++ b/src/rmdir.c @@ -91,7 +91,10 @@ main (argc, argv) usage (0); if (optind == argc) - usage (1); + { + error (0, 0, "too few arguments"); + usage (1); + } for (; optind < argc; ++optind) { diff --git a/src/sync.c b/src/sync.c index 04daa3c13..89e9d1969 100644 --- a/src/sync.c +++ b/src/sync.c @@ -19,6 +19,7 @@ #include <config.h> #include <stdio.h> +#include <sys/types.h> #include "system.h" #include "long-options.h" |