PATH_T *from;
PATH_T *to;
-#define R_FLAG (1<<0) // copy directories recursively
+#define F_FLAG (1<<3) // overwrite existing file ignoring write protection
#define I_FLAG (1<<1) // prompt before overwrite (overrides a previous -n option)
#define N_FLAG (1<<2) // do not overwrite an existing file (overrides a previous -i option)
-#define F_FLAG (1<<3) // if an existing destination file cannot be opened, remove it and try again (this option is ignored when the -n option is also used)
#define P_FLAG (1<<4) // preserve attributes and timestamps
+#define R_FLAG (1<<0) // copy directories recursively
#define V_FLAG (1<<5) // explain what is being done
static void
return;
}
copy_dir();
- /*
- * If not -p and directory didn't exist, set it to be the
- * same as the from directory, umodified by the umask;
- * arguably wrong, but it's been that way forever.
- */
-#if 0
if (flags & P_FLAG)
setfile(&from_stat, 0);
- else if (dne)
- (void)chmod(to->p_path, from_stat.st_mode);
-#endif
+
return;
}
copy_file(&from_stat, dne);
optind = 0;
int opt;
- while ((opt = getopt(argc, argv, PSTR("rfipv"))) != -1) {
+// while ((opt = getopt(argc, argv, PSTR("fiprv"))) != -1) {
+ while ((opt = getopt(argc, argv, PSTR("fiprv"))) != -1) {
switch (opt) {
case 'f':
- tflags &= ~I_FLAG;
+ tflags &= ~(I_FLAG | N_FLAG);
tflags |= F_FLAG;
break;
case 'i':
- tflags &= ~F_FLAG;
+ tflags &= ~(F_FLAG | N_FLAG);
tflags |= I_FLAG;
break;
+ case 'n':
+ tflags &= ~(F_FLAG | I_FLAG);
+ tflags |= N_FLAG;
+ break;
case 'p':
tflags |= P_FLAG;
break;
cp, CONFIG_SYS_MAXARGS, CTBL_DBG, do_cp,
"copy files",
"[-f | -i | -n] [-prv] source_file target_file\n"
- "cp [-f | -i | -n] [-prv] source_file ... target_dir\n"
+// "[-f | -i | -n] [-prv] source_file target_file\n"
+// "cp [-f | -i | -n] [-prv] source_file ... target_dir\n"
" -f overwrite existing file ignoring write protection\n"
" this option is ignored when the -n option is also used\n"
" -i prompt before overwrite (overrides a previous -n option)\n"