From 7760aed5b109683578bdaee93f82283249d1f7a1 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Tue, 5 Jun 2012 13:07:38 -0500 Subject: removal of excess code when reading from STDIN --- SBO-Lib/lib/SBO/Lib.pm | 4 +--- sboclean | 7 +++---- sboupgrade | 25 ++++++++----------------- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 0020f8e..042a4ce 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -193,9 +193,7 @@ sub slackbuilds_or_fetch { unless (check_slackbuilds_txt () ) { print "It looks like you haven't run \"sbosnap fetch\" yet.\n"; print "Would you like me to do this now? [y] "; - my $fetch = ; - $fetch = 'y' if $fetch eq "\n"; - if ($fetch =~ /^[Yy]/) { + if ( =~ /^[Yy\n]/) { fetch_tree (); } else { print "Please run \"sbosnap fetch\"\n" and exit 0; diff --git a/sboclean b/sboclean index ba710c3..e31f3ea 100755 --- a/sboclean +++ b/sboclean @@ -51,12 +51,11 @@ sub remove_stuff { my $dir = shift; opendir (my $dh, $dir); FIRST: while (my $ls = readdir $dh) { - next if $ls =~ /^\.[\.]{0,1}$/; + next FIRST if $ls =~ /^\.[\.]{0,1}$/; my $full = "$dir/$ls"; if ($interactive eq 'TRUE') { - print "Remove $full? [yn] "; - my $test = ; - next FIRST unless $test =~ /^[Yy]/; + print "Remove $full? [n] "; + next FIRST unless =~ /^[Yy]/; } unlink $full if -f $full; remove_tree $full if -d $full; diff --git a/sboupgrade b/sboupgrade index 8bf2831..bc28fd4 100755 --- a/sboupgrade +++ b/sboupgrade @@ -126,9 +126,7 @@ sub grok_requirements { print "\n". $readme_orig; print "\nIt looks like this slackbuild requires $tempname; shall I"; print " attempt to install it first? [y] "; - my $test = ; - $test = 'y' if $test eq "\n"; - if ($test =~ /^[Yy]/) { + if ( =~ /^[Yy\n]/) { my $cmd = "/usr/sbin/sboupgrade"; my @args = ('-oN'); # populate args so that they carry over correctly @@ -159,9 +157,7 @@ sub grok_user_group { print " to be run first:\n"; print " # $_\n" for @cmds; print "Shall I run it/them now? [y] "; - my $test = ; - $test = 'y' if $test eq "\n"; - if ($test =~ /^[Yy]/) { + if ( =~ /^[Yy\n]/) { for my $cmd (@cmds) { my @split = split (' ', $cmd); my $command = shift (@split); @@ -181,9 +177,7 @@ sub grok_options { print "\n". $readme; print "\nIt looks this slackbuilds has options; would you like to set any"; print " when the slackbuild is run? [n] "; - my $test = ; - $test = 'n' if $test eq "\n"; - if ($test =~ /^[Yy]/) { + if ( =~ /^[Yy]/) { print "\nPlease supply any desired options here: "; chomp (my $opts = ); die "Invalid input received.\n" @@ -204,12 +198,10 @@ sub readme_prompt { unless (grok_requirements ($sbo, $readme) ) { grok_user_group ($readme); my $opts = grok_options ($readme); - print "\n". $readme if $opts eq "7"; + print "\n". $readme if $opts == 7; my $name = $compat32 eq 'TRUE' ? "$sbo-compat32" : $sbo; print "\nProceed with $name? [y]: "; - my $test = ; - $test = 'y' if $test eq "\n"; - exit (0) unless $test =~ /^[Yy]/; + return unless =~ /^[Yy\n]/; return $opts if defined $opts; return 1; } @@ -220,8 +212,9 @@ sub process_sbos { script_error ('process_sbos requires an argument.') unless exists $_[0]; my @todo = @_; my @failures; - for my $sbo (@todo) { + FIRST: for my $sbo (@todo) { my $opts = readme_prompt ($sbo) unless $no_readme eq 'TRUE'; + next FIRST unless $opts; $opts = 'FALSE' if $opts =~ /\d+/; # switch compat32 on if upgrading a -compat32 $compat32 = 'TRUE' if $sbo =~ /-compat32$/; @@ -325,9 +318,7 @@ if ($install_new eq 'TRUE') { print "\nYou are attempting to install $sbo-compat32, however,"; print " $sbo is not yet installed. Shall I install it first?"; print " [y] "; - my $test = ; - $test = 'y' if $test eq "\n"; - if ($test =~ /^[Yy]/) { + if ( =~ /^[Yy\n]/) { my $cmd = "/usr/sbin/sboupgrade"; my @args = ('-oN', $sbo); my $out = system ($cmd, @args); -- cgit v1.2.3