aboutsummaryrefslogtreecommitdiff
path: root/sboconfig
diff options
context:
space:
mode:
authorAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-03-03 14:53:18 +0100
committerAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-03-03 14:53:18 +0100
commit30b1aa84d602a648139ae78f00b94dc9ded666bf (patch)
tree3bdaa78c53cbc18a738af15eb0cec00c9561d6d3 /sboconfig
parent5ecef1547e12d76c5a7157f65a90937511600b1b (diff)
downloadsbotools-30b1aa84d602a648139ae78f00b94dc9ded666bf.tar.xz
sbo*: Add returns to subs missing them and check @_ better
Diffstat (limited to 'sboconfig')
-rwxr-xr-xsboconfig7
1 files changed, 4 insertions, 3 deletions
diff --git a/sboconfig b/sboconfig
index 4d24256..2a90d46 100755
--- a/sboconfig
+++ b/sboconfig
@@ -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();