diff options
-rwxr-xr-x | sbocheck | 4 | ||||
-rwxr-xr-x | sboclean | 10 | ||||
-rwxr-xr-x | sboconfig | 7 | ||||
-rwxr-xr-x | sbofind | 15 | ||||
-rwxr-xr-x | sboinstall | 3 | ||||
-rwxr-xr-x | sboremove | 5 | ||||
-rwxr-xr-x | sbosnap | 3 | ||||
-rwxr-xr-x | sboupgrade | 3 |
8 files changed, 32 insertions, 18 deletions
@@ -22,7 +22,7 @@ use Data::Dumper; my $self = basename($0); sub show_usage { - print <<EOF + print <<"EOF"; Usage: $self Options: @@ -32,6 +32,7 @@ Options: version information. EOF + return 1; } my ($help, $vers); @@ -134,6 +135,7 @@ sub print_output { } else { say "\nNo updates available."; } + return 1; } my @listing = get_update_list(); @@ -21,7 +21,7 @@ use File::Path qw(remove_tree); my $self = basename($0); sub show_usage { - print <<EOF + print <<"EOF"; Usage: $self (options) [package] Options: @@ -37,6 +37,7 @@ Options: be interactive. EOF + return 1; } my ($help, $vers, $clean_dist, $clean_work, $interactive); @@ -56,7 +57,7 @@ usage_error("You must specify at least one of -d or -w.") unless ($clean_dist || $clean_work); sub rm_full { - exists $_[0] or script_error('rm_full requires an argument.'); + @_ == 1 or script_error('rm_full requires an argument.'); my $full = shift; if ($interactive) { print "Remove $full? [n] "; @@ -68,9 +69,9 @@ sub rm_full { } sub remove_stuff { - exists $_[0] or script_error 'remove_stuff requires an argument.'; - -d $_[0] or say 'Nothing to do.' and return 0; + @_ == 1 or script_error 'remove_stuff requires an argument.'; my $dir = shift; + -d $dir or say 'Nothing to do.' and return 0; opendir(my $dh, $dir); FIRST: while (my $ls = readdir $dh) { next FIRST if in($ls => qw/ . .. /); @@ -86,6 +87,7 @@ sub clean_c32 { next FIRST unless $ls =~ /^package-.+-compat32$/; rm_full("$dir/$ls"); } + return 1; } remove_stuff($config{SBO_HOME} .'/distfiles') if $clean_dist; @@ -23,7 +23,7 @@ use File::Temp qw(tempfile);; my $self = basename($0); sub show_usage { - print <<EOF + print <<"EOF"; Usage: $self [options] [arguments] Options: @@ -50,6 +50,7 @@ Config options (defaults shown): REPO: use a repository other than SBo. EOF + return 1; } my %options; @@ -128,8 +129,8 @@ if (exists $changes{SLACKWARE_VERSION}) { # them all at once, instead of only a single one and having to call it once for # each option specified to the script. sub config_write { - exists $_[1] or script_error('config_write requires two arguments.'); my ($key, $val) = @_; + @_ == 2 or script_error('config_write requires two arguments.'); if (! -d $conf_dir) { mkdir $conf_dir or usage_error("Unable to create $conf_dir. Exiting."); } @@ -147,6 +148,7 @@ sub config_write { tie my @temp, 'Tie::File', $tempfh; my $has; my $regex = qr/\A\Q$key\E=/; + # TODO: fix this monstrosity FIRST: for my $tmpline (@temp) { $has++, $tmpline = "$key=$val", last FIRST if $tmpline =~ $regex; } @@ -163,7 +165,6 @@ sub config_write { exit $exit; } print {$conffh} $contents or return(); - close $conffh, close $tempfh; } else { # no config file, easiest case of all. my ($fh, $exit) = open_fh($conf_file, '>') or return(); @@ -20,7 +20,7 @@ use Getopt::Long qw(:config bundling); my $self = basename($0); sub show_usage { - print <<EOF + print <<"EOF"; Usage: $self (search_term) Options: @@ -39,6 +39,7 @@ Example: $self libsexy EOF + return 1; } my ($help, $vers, $show_info, $show_readme, $show_queue); @@ -62,7 +63,7 @@ slackbuilds_or_fetch(); # find anything with $search in its name sub perform_search { - exists $_[0] or script_error 'perform_search requires an argument.'; + @_ == 1 or script_error 'perform_search requires an argument.'; my $search = shift; my (@findings, $name, $found); my $name_regex = qr/NAME:\s+(.*\Q$search\E.*)$/i; @@ -75,6 +76,7 @@ sub perform_search { my %local; FIRST: while (my $line = <$fh>) { unless ($found) { + # TODO: fix this monstrosity $found++, next FIRST if $name = ($line =~ $name_regex)[0]; } else { if (my ($location) = ($line =~ $loc_regex)[0]) { @@ -104,9 +106,10 @@ sub perform_search { # pull the contents of a file into a variable and format it for output sub get_file_contents { - exists $_[0] or script_error 'get_file_contents requires an argument'; - -f $_[0] or return "$_[0] doesn't exist.\n"; - my ($fh, $exit) = open_read(shift); + @_ == 1 or script_error 'get_file_contents requires an argument'; + my $file = shift; + -f $file or return "$file doesn't exist.\n"; + my ($fh, $exit) = open_read($file); if ($exit) { warn $fh; return(); @@ -121,7 +124,7 @@ sub get_file_contents { # get build queue and return it as a single line. sub show_build_queue { - exists $_[0] or script_error('show_build_queue requires an argument.'); + @_ == 1 or script_error('show_build_queue requires an argument.'); my $queue = get_build_queue([shift], {}); return join(" ", reverse @$queue); } @@ -20,7 +20,7 @@ use File::Basename; my $self = basename($0); sub show_usage { - print <<EOF + print <<"EOF"; Usage: $self [options] sbo Options (defaults shown first where applicable): @@ -44,6 +44,7 @@ Options (defaults shown first where applicable): view the README but do not parse requirements, commands, or options. EOF + return 1; } my $noclean = $config{NOCLEAN}; @@ -20,7 +20,7 @@ use File::Basename; my $self = basename ($0); sub show_usage { - print <<EOF + print <<"EOF"; Usage: $self [options] sbo Options (defaults shown first where applicable): @@ -34,6 +34,7 @@ Options (defaults shown first where applicable): Note: optional dependencies need to be removed separately. EOF + return 1; } my ($help, $vers, $non_int, $alwaysask, @excluded); @@ -92,6 +93,7 @@ sub get_reverse_reqs { } } } + return 1; } get_reverse_reqs($inst_names); @@ -119,6 +121,7 @@ sub confirm_remove { $found++ if $sbo eq $conf; } push @confirmed, $sbo unless $found; + return 1; } # Check if packages in queue are actually installed on system @@ -21,7 +21,7 @@ my $sbo_home = $config{SBO_HOME}; my $self = basename($0); sub show_usage { - print <<EOF + print <<"EOF"; Usage: $self [options|command] Options: @@ -36,6 +36,7 @@ Commands: (generally, you may prefer "sbocheck" over "$self update") EOF + return 1; } show_usage() and exit 1 unless exists $ARGV[0]; @@ -21,7 +21,7 @@ use File::Copy; my $self = basename($0); sub show_usage { - print <<EOF + print <<"EOF"; Usage: $self (options) [package] Options (defaults shown first where applicable): @@ -47,6 +47,7 @@ Options (defaults shown first where applicable): this flag will upgrade everything reported by sbocheck(1). EOF + return 1; } my $noclean = $config{NOCLEAN}; |