97389267dc9b3a859635dcf9f089bfbae0edde2c
[platform/upstream/coreutils.git] / tests / mv / i-1
1 #!/bin/sh
2
3 : ${PERL=perl}
4 : ${srcdir=.}
5
6 $PERL -e 1 > /dev/null 2>&1 || {
7   echo 1>&2 "$0: configure didn't find a usable version of Perl," \
8     "so can't run this test"
9   exit 77
10 }
11
12 exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF
13 require 5.003;
14 use strict;
15
16 (my $program_name = $0) =~ s|.*/||;
17
18 # Turn off localisation of executable's ouput.
19 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
20
21 my $test_a = 'a';
22
23 my @Tests =
24     (
25      # Make sure a `n' reply to `mv -i...' aborts the move operation.
26      [$test_a, '-i',
27       {IN => {src => "a\n"}}, {IN => {dst => "b\n"}}, '<', {IN => "n\n"},
28       {ERR => "mv: overwrite `dst'? "},
29       {POST => sub { -r 'src' or die "test $test_a failed\n"}},
30       {EXIT => 0},
31      ],
32     );
33
34 my $save_temps = $ENV{DEBUG};
35 my $verbose = $ENV{VERBOSE};
36
37 my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
38 my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
39 exit $fail;
40 EOF