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 "fs.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
eprintf("usage: %s source... dest\n", argv0);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -18,6 +24,9 @@ main(int argc, char *argv[])
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
|
if (argc < 2)
|
||||||
|
usage();
|
||||||
|
|
||||||
if(argc > 2 && !(stat(argv[argc-1], &st) == 0 && S_ISDIR(st.st_mode)))
|
if(argc > 2 && !(stat(argv[argc-1], &st) == 0 && S_ISDIR(st.st_mode)))
|
||||||
eprintf("%s: not a directory\n", argv[argc-1]);
|
eprintf("%s: not a directory\n", argv[argc-1]);
|
||||||
enmasse(argc, argv, cp);
|
enmasse(argc, argv, cp);
|
||||||
|
|
3
mkdir.c
3
mkdir.c
|
@ -29,6 +29,9 @@ main(int argc, char *argv[])
|
||||||
usage();
|
usage();
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
|
if (argc < 1)
|
||||||
|
usage();
|
||||||
|
|
||||||
for(; argc > 0; argc--, argv++) {
|
for(; argc > 0; argc--, argv++) {
|
||||||
if(pflag) {
|
if(pflag) {
|
||||||
mkdirp(argv[0]);
|
mkdirp(argv[0]);
|
||||||
|
|
4
mkfifo.c
4
mkfifo.c
|
@ -18,6 +18,10 @@ main(int argc, char *argv[])
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
|
if (argc < 1)
|
||||||
|
usage();
|
||||||
|
|
||||||
for(; argc > 0; argc--, argv++) {
|
for(; argc > 0; argc--, argv++) {
|
||||||
if(mkfifo(argv[0], S_IRUSR|S_IWUSR|S_IRGRP|\
|
if(mkfifo(argv[0], S_IRUSR|S_IWUSR|S_IRGRP|\
|
||||||
S_IWGRP|S_IROTH|S_IWOTH) == -1) {
|
S_IWGRP|S_IROTH|S_IWOTH) == -1) {
|
||||||
|
|
3
mv.c
3
mv.c
|
@ -25,6 +25,9 @@ main(int argc, char *argv[])
|
||||||
usage();
|
usage();
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
|
if (argc < 2)
|
||||||
|
usage();
|
||||||
|
|
||||||
if(argc > 3 && !(stat(argv[argc-1], &st) == 0 && S_ISDIR(st.st_mode)))
|
if(argc > 3 && !(stat(argv[argc-1], &st) == 0 && S_ISDIR(st.st_mode)))
|
||||||
eprintf("%s: not a directory\n", argv[argc-1]);
|
eprintf("%s: not a directory\n", argv[argc-1]);
|
||||||
enmasse(argc, &argv[0], mv);
|
enmasse(argc, &argv[0], mv);
|
||||||
|
|
4
rm.c
4
rm.c
|
@ -26,6 +26,10 @@ main(int argc, char *argv[])
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
|
if (argc < 1)
|
||||||
|
usage();
|
||||||
|
|
||||||
for(; argc > 0; argc--, argv++)
|
for(; argc > 0; argc--, argv++)
|
||||||
rm(argv[0]);
|
rm(argv[0]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user