From 8e6848f7b4190fb0a4890a6a177a5152c14592be Mon Sep 17 00:00:00 2001 From: John Southworth Date: Thu, 28 Apr 2011 10:41:52 -0500 Subject: verify the users intention when deleting directories since we don't have a glob --- scripts/vyatta-image-tools.pl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/vyatta-image-tools.pl b/scripts/vyatta-image-tools.pl index b343214..946d817 100755 --- a/scripts/vyatta-image-tools.pl +++ b/scripts/vyatta-image-tools.pl @@ -80,9 +80,19 @@ sub delete_file { } if (-d $file){ my $print_dir = conv_file_to_rel($topdir,$file); - if (y_or_n("Do you want to erase the entire $print_dir directory?")){ - system("rm -rf $file"); - print("Directory erased\n"); + print "This is a directory. Would you like to delete:\n" + ." Entire directory (D)\n" + ." Files in directory (F): "; + my $answer = <>; + if ($answer =~ /F|f/){ + system("rm -rf $file/*"); + } elsif ($answer =~ /D|d/){ + if (y_or_n("Do you want to erase the entire $print_dir directory?")){ + system("rm -rf $file"); + print("Directory erased\n"); + } + } else { + print "Unsupported operation\n"; } } elsif (-f $file) { my $print_file = conv_file_to_rel($topdir,$file); -- cgit v1.2.3