i-1.pl 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/perl
  2. # Make sure a 'n' reply to 'mv -i...' aborts the move operation.
  3. # Copyright (C) 2001-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. use strict;
  15. (my $program_name = $0) =~ s|.*/||;
  16. # Turn off localization of executable's output.
  17. @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
  18. my $test_a = 'a';
  19. my @Tests =
  20. (
  21. # Make sure a 'n' reply to 'mv -i...' aborts the move operation.
  22. [$test_a, '-i',
  23. {IN => {src => "a\n"}}, {IN => {dst => "b\n"}}, '<', {IN => "n\n"},
  24. {ERR => "mv: overwrite 'dst'? "},
  25. {POST => sub { -r 'src' or die "test $test_a failed\n"}},
  26. {EXIT => 0},
  27. ],
  28. );
  29. my $save_temps = $ENV{DEBUG};
  30. my $verbose = $ENV{VERBOSE};
  31. my $prog = 'mv';
  32. my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
  33. exit $fail;