diff options
author | Adam Spiers <stow@adamspiers.org> | 2019-06-25 15:55:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-25 15:55:15 +0100 |
commit | a70c60e888d572b95326e0223cbaa39fbcab58b0 (patch) | |
tree | 3a44d32dbdd0d2e58751bebccce98edab4b09902 | |
parent | 1e9fa23d2e21937bef74eee3223b752d4a7bdca3 (diff) | |
parent | e79c5938bc8bc756990c0eb80c52bb1302d02997 (diff) | |
download | stow-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-x | bin/stow.in | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | t/cli.t | 6 |
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}; @@ -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 |