Skip to content

Commit 04d90b4

Browse files
authored
rm: unexpected confirmation prompt (briandfoy#957)
* When attempting to remove a file that doesn't exist, rm shows a prompt about the file being read-only * If I then confirm by typing "y", I see the unlink() error which explains the file wasn't found * Bypass the prompt by adding an -e file check; the "-w FILE" is false if FILE doesn't exist
1 parent 88def99 commit 04d90b4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

bin/rm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ sub remove_file {
259259
$self->message( "$filename: ? " );
260260
return OP_SUCCEEDED if <STDIN> =~ /^[Nn]/;
261261
}
262-
elsif( !$self->is_force && ! -w $filename ) {
262+
elsif( !$self->is_force && -e $filename && ! -w $filename ) {
263263
$self->message( "$filename: Read-only ? " );
264264
return OP_SUCCEEDED if <STDIN> =~ /^[Nn]/;
265265
}

0 commit comments

Comments
 (0)