Skip to content

Commit

Permalink
Fix exit code for h option
Browse files Browse the repository at this point in the history
Surprised to find out that the h option has been broken from the start.
  • Loading branch information
mptre committed Nov 5, 2017
1 parent 54b1e43 commit f833b3a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pick.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static const char *tty_parm1(const char *, int);
static int tty_putc(int);
static void tty_restore(int);
static void tty_size(void);
static __dead void usage(void);
static __dead void usage(int);
static int xmbtowc(wchar_t *, const char *);

static struct termios tio;
Expand Down Expand Up @@ -133,6 +133,8 @@ main(int argc, char *argv[])
case 'd':
descriptions = 1;
break;
case 'h':
usage(0);
case 'K':
use_keypad = 0;
break;
Expand Down Expand Up @@ -162,12 +164,12 @@ main(int argc, char *argv[])
use_alternate_screen = 0;
break;
default:
usage();
usage(1);

This comment has been minimized.

Copy link
@mptre

mptre Nov 5, 2017

Author Owner

See #183.

This comment has been minimized.

Copy link
@mptre

mptre Nov 7, 2017

Author Owner

Although, they are defined by POSIX; I don't think such churn adds
value (might not comes as a surprise :-)). Thoughts @calleerlandsson?

}
argc -= optind;
argv += optind;
if (argc > 0)
usage();
usage(1);

if (query == NULL) {
query_size = 64;
Expand Down Expand Up @@ -201,7 +203,7 @@ main(int argc, char *argv[])
}

__dead void
usage(void)
usage(int status)
{
fprintf(stderr, "usage: pick [-hvKS] [-d [-o]] [-x | -X] [-q query]\n"
" -h output this help message and exit\n"
Expand All @@ -214,7 +216,7 @@ usage(void)
" -X disable alternate screen\n"
" -q query supply an initial search query\n");

exit(1);
exit(status);
}

char *
Expand Down

0 comments on commit f833b3a

Please sign in to comment.