Skip to content

Commit

Permalink
Fix root-level help.
Browse files Browse the repository at this point in the history
  • Loading branch information
biot committed Dec 5, 2014
1 parent acb9b00 commit ca84bed
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tokenline.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ static void show_help(t_tokenline *tl, int *words, int num_words)

(void)words;

if (tl->parsed.last_token_entry->help) {
if (tl->parsed.last_token_entry && tl->parsed.last_token_entry->help) {
tl->print(tl->user, tl->parsed.last_token_entry->help);
tl->print(tl->user, NL);
}
Expand All @@ -569,7 +569,8 @@ static void show_help(t_tokenline *tl, int *words, int num_words)
tl->print(tl->user, NL);
}
}
if (!tl->parsed.last_token_entry->help && !tokens)
if ((!tl->parsed.last_token_entry || !tl->parsed.last_token_entry->help)
&& !tokens)
tl->print(tl->user, NO_HELP);
}

Expand All @@ -590,9 +591,7 @@ static void process_line(t_tokenline *tl)
if (!strcmp(tl->buf + words[0], "help")) {
/* Tokenize with errors turned off. */
tokenize(tl, words + 1, num_words - 1, &tokens, NULL);
if (tl->parsed.last_token_entry) {
show_help(tl, words, num_words);
}
show_help(tl, words, num_words);
} else if (!strcmp(tl->buf + words[0], "history")) {
history_show(tl);
} else {
Expand Down

0 comments on commit ca84bed

Please sign in to comment.