into-self-2.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/bin/sh
  2. # Force mv to use the copying code.
  3. # Consider the case where SRC and DEST are on different
  4. # partitions and DEST is a symlink to SRC.
  5. # Copyright (C) 1998-2018 Free Software Foundation, Inc.
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
  17. print_ver_ mv
  18. cleanup_() { rm -rf "$other_partition_tmpdir"; }
  19. . "$abs_srcdir/tests/other-fs-tmpdir"
  20. file="$other_partition_tmpdir/file"
  21. symlink=symlink
  22. echo whatever > $file || framework_failure_
  23. ln -s $file $symlink || framework_failure_
  24. # This mv command should exit nonzero.
  25. mv $symlink $file > out 2>&1 && fail=1
  26. # This should succeed.
  27. mv $file $symlink || fail=1
  28. sed \
  29. -e "s,mv:,XXX:," \
  30. -e "s,$file,YYY," \
  31. -e "s,$symlink,ZZZ," \
  32. out > out2
  33. cat > exp <<\EOF
  34. XXX: 'ZZZ' and 'YYY' are the same file
  35. EOF
  36. #'
  37. compare exp out2 || fail=1
  38. Exit $fail