~ubuntu-branches/ubuntu/vivid/safe-rm/vivid

« back to all changes in this revision

Viewing changes to safe-rm

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2008-11-09 16:34:46 UTC
  • mfrom: (5.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081109163446-f9o04599y4c0l579
Tags: 0.4-2
Always run rm even when there are no arguments left (closes: #505003)

Show diffs side-by-side

added added

removed removed

Lines of Context:
136
136
        $normalized_pathname = realpath($normalized_pathname);
137
137
        $normalized_pathname = $pathname unless $normalized_pathname;
138
138
    }
139
 
    if ($normalized_pathname =~ m|^(.*?)/+$|) {
 
139
    if ($normalized_pathname =~ m|^(.+?)/+$|) {
140
140
        # Trim trailing slashes
141
141
        $normalized_pathname = $1;
142
142
    }
149
149
    }
150
150
}
151
151
 
152
 
# Run rm if there is at least one argument left
 
152
# Run rm
153
153
my $errcode = 0;
154
 
if (@allowed_args > 0) {
155
 
    my $real_rm = '/bin/rm';
156
 
    if (realpath($real_rm) eq realpath($0)) {
157
 
        die 'Cannot find the real "rm" binary';
158
 
    }
159
 
    my $status = system($real_rm, @allowed_args);
160
 
    $errcode = $status >> 8;
 
154
my $real_rm = '/bin/rm';
 
155
if (realpath($real_rm) eq realpath($0)) {
 
156
    die 'Cannot find the real "rm" binary';
161
157
}
 
158
my $status = system($real_rm, @allowed_args);
 
159
$errcode = $status >> 8;
162
160
exit $errcode;