summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Spiers <stow@adamspiers.org>2019-06-25 15:55:15 +0100
committerGitHub <noreply@github.com>2019-06-25 15:55:15 +0100
commita70c60e888d572b95326e0223cbaa39fbcab58b0 (patch)
tree3a44d32dbdd0d2e58751bebccce98edab4b09902
parent1e9fa23d2e21937bef74eee3223b752d4a7bdca3 (diff)
parente79c5938bc8bc756990c0eb80c52bb1302d02997 (diff)
downloadstow-a70c60e888d572b95326e0223cbaa39fbcab58b0.tar.gz
Merge pull request #37 from aspiers/invalid-option-exit-code
Return non-zero exit code when invalid option is specified (#34)
-rwxr-xr-xbin/stow.in2
-rwxr-xr-x[-rw-r--r--]t/cli.t6
2 files changed, 6 insertions, 2 deletions
diff --git a/bin/stow.in b/bin/stow.in
index 98b576e..adff6de 100755
--- a/bin/stow.in
+++ b/bin/stow.in
@@ -539,7 +539,7 @@ sub process_options {
push @pkgs_to_stow, $_[0];
}
},
- ) or usage();
+ ) or usage('');
usage() if $options{help};
version() if $options{version};
diff --git a/t/cli.t b/t/cli.t
index 0fc0528..010fc79 100644..100755
--- a/t/cli.t
+++ b/t/cli.t
@@ -8,7 +8,7 @@ use strict;
use warnings;
use File::Basename;
-use Test::More tests => 1;
+use Test::More tests => 3;
use testutil;
@@ -47,4 +47,8 @@ my $STOW = 'bin/stow';
`$STOW --help`;
is($?, 0, "--help should return 0 exit code");
+my $err = `$STOW --foo 2>&1`;
+is($? >> 8, 1, "unrecognised option should return 1 exit code");
+like($err, qr/^Unknown option: foo$/m, "unrecognised option should be listed");
+
# vim:ft=perl