interactive-always.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/sh
  2. # Test the --interactive[=WHEN] changes added to coreutils 6.0
  3. # Copyright (C) 2006-2018 Free Software Foundation, Inc.
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
  15. print_ver_ rm
  16. touch file1-1 file1-2 file2-1 file2-2 file3-1 file3-2 file4-1 file4-2 \
  17. || framework_failure_
  18. # If asked, answer no to first question, then yes to second.
  19. echo 'n
  20. y' > in || framework_failure_
  21. rm -f out err || framework_failure_
  22. # The prompt has a trailing space, and no newline, so an extra
  23. # 'echo .' is inserted after each rm to make it obvious what was asked.
  24. echo 'no WHEN' > err || framework_failure_
  25. rm -R --interactive file1-* < in >> out 2>> err || fail=1
  26. echo . >> err || framework_failure_
  27. test -f file1-1 || fail=1
  28. test -f file1-2 && fail=1
  29. echo 'WHEN=never' >> err || framework_failure_
  30. rm -R --interactive=never file2-* < in >> out 2>> err || fail=1
  31. echo . >> err || framework_failure_
  32. test -f file2-1 && fail=1
  33. test -f file2-2 && fail=1
  34. echo 'WHEN=once' >> err || framework_failure_
  35. rm -R --interactive=once file3-* < in >> out 2>> err || fail=1
  36. echo . >> err || framework_failure_
  37. test -f file3-1 || fail=1
  38. test -f file3-2 || fail=1
  39. echo 'WHEN=always' >> err || framework_failure_
  40. rm -R --interactive=always file4-* < in >> out 2>> err || fail=1
  41. echo . >> err || framework_failure_
  42. test -f file4-1 || fail=1
  43. test -f file4-2 && fail=1
  44. echo '-f overrides --interactive' >> err || framework_failure_
  45. rm -R --interactive=once -f file1-* < in >> out 2>> err || fail=1
  46. echo . >> err || framework_failure_
  47. test -f file1-1 && fail=1
  48. echo '--interactive overrides -f' >> err || framework_failure_
  49. rm -R -f --interactive=once file4-* < in >> out 2>> err || fail=1
  50. echo . >> err || framework_failure_
  51. test -f file4-1 || fail=1
  52. cat <<\EOF > experr.t || framework_failure_
  53. no WHEN
  54. @remove_empty 'file1-1'? @remove_empty 'file1-2'? .
  55. WHEN=never
  56. .
  57. WHEN=once
  58. rm: remove 2 arguments recursively? .
  59. WHEN=always
  60. @remove_empty 'file4-1'? @remove_empty 'file4-2'? .
  61. -f overrides --interactive
  62. .
  63. --interactive overrides -f
  64. rm: remove 1 argument recursively? .
  65. EOF
  66. sed 's/@remove_empty/rm: remove regular empty file/g' < experr.t > experr ||
  67. framework_failure_
  68. compare /dev/null out || fail=1
  69. compare experr err || fail=1
  70. Exit $fail