El 2020-07-30 21:20, Michael Siegel escribió:
Am 26.07.20 um 01:11 schrieb Matias Fonzo:
El 2020-07-24 20:21, Michael Siegel escribió:
Am 24.07.20 um 23:29 schrieb Matias Fonzo:
El 2020-07-24 17:42, Michael Siegel escribió:
Okay, next thing: I would suggest using a "here-document"[1] to
implement the `usage()' function. This will make the code much
more
readable.
What's wrong with printf?
I think there are several things wrong with that:
[...]
I am attaching a version of Qi that uses heredoc for clarity,
avoiding
invoking cat(1) to print help.
Nice. But why would you re-implement cat(1) for this? I wouldn't do
that, for two reasons:
* Displaying help text is a one-shot operation, i.e., `cat'-ing that
heredoc is the only actual action Qi has to perform when called
with
`--help'. In other words: This really doesn't need to be optimized
for speed. Running `printf' in a loop is probably not providing
much
of an optimization there anyway.
I do not consider that invoking an external tool is reliable to show
the help of a program/script (do you know any language that does
this?). So optimization doesn't matter much here.
(Anyway, I can switch to echo, since printf is more effective (faster)
when you have to print several lines, and knowing what the expected
output is, I think there will be no problem using echo instead of
printf).