Skip to content

Commit 616a2db

Browse files
authored
cp -i: continue on prompt (#827)
* cp can copy multiple files to a destination * It is not an error for the user to type "n" to not clobber an existing file when running (cp -i) * Previously if I type "n" cp will exit with a failure code and ignore the remaining files I want to copy %mkdir dest && perl cp -v a.c ar dest && perl cp -i a.c ar dest a.c -> dest/a.c ar -> dest/ar overwrite dest/a.c? (y/n [n]) [n] n overwrite dest/ar? (y/n [n]) [n] y %echo $? 0
1 parent 36ffa5f commit 616a2db

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

bin/cp

+1-4
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ sub run {
8080
print { output_fh() } "$source -> $catdst\n" if $opts->{v};
8181
if( -e $catdst and $opts->{i} and ! $opts->{f} ) {
8282
my $answer = prompt( "overwrite $catdst? (y/n [n])", 'n' );
83-
unless( $answer =~ m/\A\s*y/i ) {
84-
print { error_fh() } "not overwritten";
85-
return EX_FAILURE;
86-
}
83+
next unless $answer =~ m/\A\s*y/i;
8784
}
8885
if (File::Copy::copy($source, $catdst) == 0) {
8986
print { error_fh() } "$0: $source -> $catdst: copy failed: $!\n";

0 commit comments

Comments
 (0)