@@ -2856,3 +2856,82 @@ fn test_mv_no_prompt_unwriteable_file_with_no_tty() {
28562856 assert ! ( !at. file_exists( "source_notty" ) ) ;
28572857 assert ! ( at. file_exists( "target_notty" ) ) ;
28582858}
2859+
2860+ #[ test]
2861+ fn test_mv_dir_symlink_slash_to_dest_dir ( ) {
2862+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
2863+
2864+ at. mkdir ( "foo" ) ;
2865+ at. symlink_dir ( "foo" , "symlink" ) ;
2866+
2867+ ucmd. arg ( "symlink/" )
2868+ . arg ( "foo" )
2869+ . fails ( )
2870+ . stderr_contains ( "cannot move 'symlink/' to 'foo/symlink': Not a directory" ) ;
2871+ }
2872+
2873+ #[ test]
2874+ fn test_mv_dir_symlink_slash_to_another_dir ( ) {
2875+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
2876+
2877+ at. mkdir ( "foo" ) ;
2878+ at. mkdir ( "target" ) ;
2879+ at. symlink_dir ( "foo" , "symlink_foo" ) ;
2880+
2881+ ucmd. arg ( "symlink_foo/" )
2882+ . arg ( "target" )
2883+ . fails ( )
2884+ . stderr_contains ( "cannot move 'symlink_foo/' to 'target/symlink_foo': Not a directory" ) ;
2885+ }
2886+
2887+ #[ test]
2888+ fn test_mv_file_symlink_slash_to_dir ( ) {
2889+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
2890+
2891+ at. touch ( "a" ) ;
2892+ at. mkdir ( "target" ) ;
2893+ at. symlink_file ( "a" , "symlink_a" ) ;
2894+
2895+ ucmd. arg ( "symlink/" )
2896+ . arg ( "target" )
2897+ . fails ( )
2898+ . stderr_contains ( "cannot stat 'symlink/': Not a directory" ) ;
2899+ }
2900+
2901+ #[ test]
2902+ fn test_mv_dir_symlink_slash_to_file ( ) {
2903+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
2904+
2905+ at. touch ( "a" ) ;
2906+ at. mkdir ( "foo" ) ;
2907+ at. symlink_dir ( "foo" , "symlink_foo" ) ;
2908+
2909+ ucmd. arg ( "symlink_foo/" )
2910+ . arg ( "a" )
2911+ . fails ( )
2912+ . stderr_contains ( "cannot overwrite non-directory 'a' with directory 'symlink_foo/'" ) ;
2913+ }
2914+
2915+ #[ test]
2916+ fn test_mv_file_symlink_slash_to_dest_file ( ) {
2917+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
2918+ at. touch ( "a" ) ;
2919+ at. symlink_dir ( "a" , "symlink_a" ) ;
2920+
2921+ ucmd. arg ( "symlink_a/" )
2922+ . arg ( "a" )
2923+ . fails ( )
2924+ . stderr_contains ( "cannot stat 'symlink_a/': Not a directory" ) ;
2925+ }
2926+ #[ test]
2927+ fn test_mv_file_symlink_slash_to_another_file ( ) {
2928+ let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
2929+ at. touch ( "a" ) ;
2930+ at. touch ( "b" ) ;
2931+ at. symlink_dir ( "a" , "symlink_a" ) ;
2932+
2933+ ucmd. arg ( "symlink_a/" )
2934+ . arg ( "b" )
2935+ . fails ( )
2936+ . stderr_contains ( "cannot stat 'symlink_a/': Not a directory" ) ;
2937+ }
0 commit comments