diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-01-28 06:25:08 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-01-28 06:25:08 -0800 |
commit | de7bf991a1a114cd587109b8c632f5efef166930 (patch) | |
tree | 8b772043f168522d0b13c59ef7630c0c4e39aea3 /txr.c | |
parent | d864d3cdcccd4e712fad5fdc1a33209b15fa0aab (diff) | |
download | txr-de7bf991a1a114cd587109b8c632f5efef166930.tar.gz txr-de7bf991a1a114cd587109b8c632f5efef166930.tar.bz2 txr-de7bf991a1a114cd587109b8c632f5efef166930.zip |
command line: better diagnosis for --args and --eargs
* txr.c (txr_main): Diagnose accurately when --args
or --eargs is specified without any of the required trailing
syntax, instead of complaining about --args or --eargs being an
unknown option. Also, fix the error message about --eargs not having
an argument, such that it doesn't insinuate that there exists
an --eargs=value syntax.
Diffstat (limited to 'txr.c')
-rw-r--r-- | txr.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -575,8 +575,14 @@ int txr_main(int argc, char **argv) /* Odd case 1: --args is followed by an arbitrary delimiting * character, not necessarily = */ - if (match_str(arg, lit("--args"), zero) && ge(length(arg), num(7))) { + if (match_str(arg, lit("--args"), zero)) { val sep = sub_str(arg, num(6), num(7)); + if (empty(sep)) { + format(std_error, + lit("~a: --args requires argument material\n"), + prog_string, nao); + return EXIT_FAILURE; + } arg = sub_str(arg, num(7), nil); arg_list = append2(split_str(arg, sep), arg_list); set(eff_arg_tail, butlastn(one, deref(eff_arg_tail))); @@ -585,12 +591,18 @@ int txr_main(int argc, char **argv) /* Odd case 2: --eargs is followed by an arbitrary delimiting * character, not necessarily = */ - if (match_str(arg, lit("--eargs"), zero) && ge(length(arg), num(8))) { + if (match_str(arg, lit("--eargs"), zero)) { val sep = sub_str(arg, num(7), num(8)); val arg2; + if (empty(sep)) { + format(std_error, + lit("~a: --eargs requires argument material\n"), + prog_string, nao); + return EXIT_FAILURE; + } if (!arg_list) { format(std_error, - lit("~a: --eargs=[...] must be followed by an argument\n"), + lit("~a: --eargs must be followed by an argument\n"), prog_string, nao); return EXIT_FAILURE; } |