hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 9e5a68a651bd8e29db0b384717ce7068bf52b235
parent 7c8be881cf6e4cc541d9ff89799671afc820cb80
Author: Byron Torres <b@torresjrjr.com>
Date:   Sat, 11 Dec 2021 11:40:35 +0000

getopt: fix mishandled len(help) == 0

Signed-off-by: Byron Torres <b@torresjrjr.com>

Diffstat:
Mgetopt/getopts.ha | 4++++
1 file changed, 4 insertions(+), 0 deletions(-)

diff --git a/getopt/getopts.ha b/getopt/getopts.ha @@ -231,6 +231,10 @@ export fn printusage(out: io::handle, name: str, help: []help) void = { // Prints command help to the provided stream. export fn printhelp(out: io::handle, name: str, help: []help) void = { + if (len(help) == 0) { + return; + }; + if (help[0] is cmd_help) { fmt::fprintfln(out, "{}: {}\n", name, help[0] as cmd_help: str)!; };