File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed
Expand file tree Collapse file tree 2 files changed +33
-4
lines changed Original file line number Diff line number Diff line change @@ -440,13 +440,19 @@ fn rename(
440440
441441 match b. overwrite {
442442 OverwriteMode :: NoClobber => {
443- return Err ( io:: Error :: new (
444- io:: ErrorKind :: Other ,
445- format ! ( "not replacing {}" , to. quote( ) ) ,
446- ) ) ;
443+ let err_msg = if b. verbose {
444+ println ! ( "skipped {}" , to. quote( ) ) ;
445+ String :: new ( )
446+ } else {
447+ format ! ( "not replacing {}" , to. quote( ) )
448+ } ;
449+ return Err ( io:: Error :: new ( io:: ErrorKind :: Other , err_msg) ) ;
447450 }
448451 OverwriteMode :: Interactive => {
449452 if !prompt_yes ! ( "overwrite {}?" , to. quote( ) ) {
453+ if b. verbose {
454+ println ! ( "skipped {}" , to. quote( ) ) ;
455+ }
450456 return Err ( io:: Error :: new ( io:: ErrorKind :: Other , "" ) ) ;
451457 }
452458 }
Original file line number Diff line number Diff line change @@ -1243,6 +1243,29 @@ fn test_mv_info_self() {
12431243 . stderr_contains ( "mv: cannot move 'dir2' to a subdirectory of itself, 'dir2/dir2'" ) ;
12441244}
12451245
1246+ #[ test]
1247+ fn test_mv_arg_interactive_skipped ( ) {
1248+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
1249+ at. touch ( "a" ) ;
1250+ at. touch ( "b" ) ;
1251+ ucmd. args ( & [ "-vi" , "a" , "b" ] )
1252+ . pipe_in ( "N\n " )
1253+ . ignore_stdin_write_error ( )
1254+ . fails ( )
1255+ . stderr_is ( "mv: overwrite 'b'? " )
1256+ . stdout_is ( "skipped 'b'\n " ) ;
1257+ }
1258+
1259+ #[ test]
1260+ fn test_mv_arg_interactive_skipped_vin ( ) {
1261+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
1262+ at. touch ( "a" ) ;
1263+ at. touch ( "b" ) ;
1264+ ucmd. args ( & [ "-vin" , "a" , "b" ] )
1265+ . fails ( )
1266+ . stdout_is ( "skipped 'b'\n " ) ;
1267+ }
1268+
12461269#[ test]
12471270fn test_mv_into_self_data ( ) {
12481271 let scene = TestScenario :: new ( util_name ! ( ) ) ;
You can’t perform that action at this time.
0 commit comments