cksum: ensure appropriate "binary" mode with --untagged
[coreutils.git] / tests / rm / empty-name.pl
blob5835174600a709574bd567c9d1c91e6e6b79de20
1 #!/usr/bin/perl
2 # Make sure that rm -r '' fails.
4 # Copyright (C) 1998-2024 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.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 # On SunOS 4.1.3, running rm -r '' in a nonempty directory may
20 # actually remove files with names of entries in the current directory
21 # but relative to '/' rather than relative to the current directory.
23 use strict;
25 (my $program_name = $0) =~ s|.*/||;
27 # Turn off localization of executable's output.
28 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
30 my $prog = 'rm';
32 # FIXME: copied from misc/ls-misc; factor into Coreutils.pm?
33 sub mk_file(@)
35 foreach my $f (@_)
37 open (F, '>', $f) && close F
38 or die "creating $f: $!\n";
42 my @Tests =
44 # test-name options input expected-output
46 ['empty-name-1', "''", {EXIT => 1},
47 {ERR => "$prog: cannot remove '': No such file or directory\n"}],
49 ['empty-name-2', "a '' b", {EXIT => 1},
50 {ERR => "$prog: cannot remove '': No such file or directory\n"},
51 {PRE => sub { mk_file qw(a b) }},
52 {POST => sub {-f 'a' || -f 'b' and die "a or b remain\n" }},
56 my $save_temps = $ENV{SAVE_TEMPS};
57 my $verbose = $ENV{VERBOSE};
59 my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
60 exit $fail;