=== modified file 'uspace/app/bdsh/cmds/modules/cp/cp.c'
--- uspace/app/bdsh/cmds/modules/cp/cp.c	2011-10-29 17:02:30 +0000
+++ uspace/app/bdsh/cmds/modules/cp/cp.c	2012-04-04 10:40:40 +0000
@@ -49,6 +49,7 @@
 static struct option const long_options[] = {
 	{ "buffer", required_argument, 0, 'b' },
 	{ "force", no_argument, 0, 'f' },
+	{ "interactive", no_argument, 0, 'i'},
 	{ "recursive", no_argument, 0, 'r' },
 	{ "help", no_argument, 0, 'h' },
 	{ "version", no_argument, 0, 'v' },
@@ -138,10 +139,34 @@
 	str_append(path1, path1_size, path2);
 }
 
+static bool get_user_decision(const char *message, bool bdefault)
+{
+	char test_char;
+
+	for(;;) {
+		printf(message);
+		test_char = fgetc(stdin);
+		printf("\n");
+
+		switch(test_char) {
+		case 'y':
+		case 'Y':
+			return true;
+			break;
+		case 'n':
+		case 'N':
+			return false;
+			break;
+		case '\n':
+			return bdefault;
+		}
+	}
+}
+
 static int64_t do_copy(const char *src, const char *dest,
-    size_t blen, int vb, int recursive, int force)
+    size_t blen, int vb, int recursive, int force, int interactive)
 {
-	int r = -1;
+	int r = 0;
 	char dest_path[PATH_MAX];
 	char src_path[PATH_MAX];
 	DIR *dir = NULL;
@@ -191,17 +216,36 @@
 		} else if (dest_type == TYPE_FILE) {
 			/* e.g. cp file_name existing_file */
 
-			/* dest already exists, if force is set we will
-			 * try to remove it.
+			/* dest already exists, 
+			 * if force is set we will try to remove it.
+			 * if interactive is set user input is required.
 			 */
-			if (force) {
+			if (force && !interactive) {
 				if (unlink(dest_path)) {
 					printf("Unable to remove %s\n",
 					    dest_path);
+					r = -1;
+					goto exit;
+				}
+			} else if (!force && interactive) {
+				char message[60];
+
+				snprintf(message, 41+str_size(dest_path), 
+				    "File already exists: %s. Overwrite? [y/N]: ", dest_path);
+
+				if(get_user_decision(message, false)) {
+					printf("Overwriting file: %s\n", dest_path);
+					if (unlink(dest_path)) {
+						printf("Unable to remove %s\n",dest_path);
+						r = -1;
+						goto exit;
+					}
+				} else {
+					printf("Not overwriting file: %s\n", dest_path);
 					goto exit;
 				}
 			} else {
-				printf("file already exists: %s\n", dest_path);
+				printf("File already exists: %s\n", dest_path);
 				goto exit;
 			}
 		}
@@ -301,7 +345,7 @@
 
 			/* Recursively call do_copy() */
 			r = do_copy(src_dent, dest_dent, blen, vb, recursive,
-			    force);
+			    force, interactive);
 			if (r)
 				goto exit;
 
@@ -379,7 +423,8 @@
 	    "  -h, --help       A short option summary\n"
 	    "  -v, --version    Print version information and exit\n"
 	    "  -V, --verbose    Be annoyingly noisy about what's being done\n"
-	    "  -f, --force      Do not complain when <dest> exists\n"
+	    "  -f, --force      Do not complain when <dest> exists (overrides a previous -i)\n"
+	    "  -i, --interactive Ask what to do when <dest> exists (overrides a previous -f)\n"
 	    "  -r, --recursive  Copy entire directories\n"
 	    "  -b, --buffer ## Set the read buffer size to ##\n";
 	if (level == HELP_SHORT) {
@@ -396,14 +441,14 @@
 {
 	unsigned int argc, verbose = 0;
 	int buffer = 0, recursive = 0;
-	int force = 0;
+	int force = 0, interactive = 0;
 	int c, opt_ind;
 	int64_t ret;
 
 	argc = cli_count_args(argv);
 
 	for (c = 0, optind = 0, opt_ind = 0; c != -1;) {
-		c = getopt_long(argc, argv, "hvVfrb:", long_options, &opt_ind);
+		c = getopt_long(argc, argv, "hvVfirb:", long_options, &opt_ind);
 		switch (c) { 
 		case 'h':
 			help_cmd_cp(1);
@@ -415,8 +460,13 @@
 			verbose = 1;
 			break;
 		case 'f':
+			interactive = 0;
 			force = 1;
 			break;
+		case 'i':
+			force = 0;
+			interactive = 1;
+			break;
 		case 'r':
 			recursive = 1;
 			break;
@@ -445,7 +495,7 @@
 	}
 
 	ret = do_copy(argv[optind], argv[optind + 1], buffer, verbose,
-	    recursive, force);
+	    recursive, force, interactive);
 
 	if (ret == 0)
 		return CMD_SUCCESS;

