From 3591a89dbc5229de9659cbb8626ee82ca34c089b Mon Sep 17 00:00:00 2001 From: Andreas Guldstrand Date: Mon, 18 Apr 2016 00:01:42 +0200 Subject: sbosnap: Make argument checking more streamlined --- sbosnap | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/sbosnap b/sbosnap index 1d835ab..f2777b8 100755 --- a/sbosnap +++ b/sbosnap @@ -46,18 +46,16 @@ GetOptions('help|h' => \$help, 'version|v' => \$vers); if ($help) { show_usage(); exit 0 } if ($vers) { show_version(); exit 0 } -if (!@ARGV) { show_usage(); exit 1 } - # check for a command and, if found, execute it -my $command; -if ($ARGV[0] =~ /fetch|update/) { - $command = $ARGV[0]; -} else { +$ARGV[0] //= ''; + +if ($ARGV[0] eq 'fetch') { + fetch_tree() +} elsif ($ARGV[0] eq 'update') { + update_tree() +} else { show_usage(); exit 1; } -if ($command eq 'fetch') { fetch_tree() } -elsif ($command eq 'update') { update_tree() } - exit 0; -- cgit v1.2.3