None of these work without the proper # of arguments so print usage
This commit is contained in:
parent
355911f010
commit
428cd4fe84
9
cp.c
9
cp.c
|
@ -5,6 +5,12 @@
|
|||
#include "fs.h"
|
||||
#include "util.h"
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
eprintf("usage: %s source... dest\n", argv0);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -18,6 +24,9 @@ main(int argc, char *argv[])
|
|||
exit(EXIT_FAILURE);
|
||||
} ARGEND;
|
||||
|
||||
if (argc < 2)
|
||||
usage();
|
||||
|
||||
if(argc > 2 && !(stat(argv[argc-1], &st) == 0 && S_ISDIR(st.st_mode)))
|
||||
eprintf("%s: not a directory\n", argv[argc-1]);
|
||||
enmasse(argc, argv, cp);
|
||||
|
|
3
mkdir.c
3
mkdir.c
|
@ -29,6 +29,9 @@ main(int argc, char *argv[])
|
|||
usage();
|
||||
} ARGEND;
|
||||
|
||||
if (argc < 1)
|
||||
usage();
|
||||
|
||||
for(; argc > 0; argc--, argv++) {
|
||||
if(pflag) {
|
||||
mkdirp(argv[0]);
|
||||
|
|
4
mkfifo.c
4
mkfifo.c
|
@ -18,6 +18,10 @@ main(int argc, char *argv[])
|
|||
default:
|
||||
usage();
|
||||
} ARGEND;
|
||||
|
||||
if (argc < 1)
|
||||
usage();
|
||||
|
||||
for(; argc > 0; argc--, argv++) {
|
||||
if(mkfifo(argv[0], S_IRUSR|S_IWUSR|S_IRGRP|\
|
||||
S_IWGRP|S_IROTH|S_IWOTH) == -1) {
|
||||
|
|
3
mv.c
3
mv.c
|
@ -25,6 +25,9 @@ main(int argc, char *argv[])
|
|||
usage();
|
||||
} ARGEND;
|
||||
|
||||
if (argc < 2)
|
||||
usage();
|
||||
|
||||
if(argc > 3 && !(stat(argv[argc-1], &st) == 0 && S_ISDIR(st.st_mode)))
|
||||
eprintf("%s: not a directory\n", argv[argc-1]);
|
||||
enmasse(argc, &argv[0], mv);
|
||||
|
|
4
rm.c
4
rm.c
|
@ -26,6 +26,10 @@ main(int argc, char *argv[])
|
|||
default:
|
||||
usage();
|
||||
} ARGEND;
|
||||
|
||||
if (argc < 1)
|
||||
usage();
|
||||
|
||||
for(; argc > 0; argc--, argv++)
|
||||
rm(argv[0]);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user