arguments to be interpreted as file names. This allows file names
starting with - to be specified.
SCCS-vsn: bin/mv/mv.c 4.2
SCCS-vsn: bin/rm/rm.c 4.2
-static char *sccsid = "@(#)mv.c 4.1 (Berkeley) %G%";
+static char *sccsid = "@(#)mv.c 4.2 (Berkeley) %G%";
register char *argv[];
{
register i, r;
register char *argv[];
{
register i, r;
/* get the flag(s) */
if (argc < 2)
goto usage;
/* get the flag(s) */
if (argc < 2)
goto usage;
+ while (argc>1 && *argv[1] == '-') {
- while (*++argv[1] != '\0')
- switch (*argv[1]) {
+ arg = *++argv;
+
+ /*
+ * all files following a null option are considered file names
+ */
+ if (*(arg+1) == '\0') break;
+
+ while (*++arg != '\0')
+ switch (*arg) {
/* interactive mode */
case 'i':
/* interactive mode */
case 'i':
}
if (argc < 3)
goto usage;
}
if (argc < 3)
goto usage;
r |= move(argv[i], argv[argc-1]);
return(r);
usage:
r |= move(argv[i], argv[argc-1]);
return(r);
usage:
- fprintf(stderr, "usage: mv f1 f2; or mv d1 d2; or mv f1 ... fn d1\n");
+ fprintf(stderr, "usage: mv [-if] f1 f2; or mv [-if] d1 d2; or mv [-if] f1 ... fn d1\n");
-static char *sccsid = "@(#)rm.c 4.1 (Berkeley) %G%";
+static char *sccsid = "@(#)rm.c 4.2 (Berkeley) %G%";
int errcode;
#include <stdio.h>
int errcode;
#include <stdio.h>
while(argc>1 && argv[1][0]=='-') {
arg = *++argv;
argc--;
while(argc>1 && argv[1][0]=='-') {
arg = *++argv;
argc--;
+
+ /*
+ * all files following a null option are considered file names
+ */
+ if (*(arg+1) == '\0') break;
+
while(*++arg != '\0')
switch(*arg) {
case 'f':
while(*++arg != '\0')
switch(*arg) {
case 'f':