dragora-members
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Dragora-members] Qi 2.0rc14


From: Matias Fonzo
Subject: Re: [Dragora-members] Qi 2.0rc14
Date: Thu, 30 Jul 2020 22:29:49 -0300
User-agent: Roundcube Webmail/1.4.6

El 2020-07-30 22:15, Matias Fonzo escribió:
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).


UPDATE: I replaced the current lines with a printf ala:

printf '%s\n' \
"
Usage: $PROGRAM COMMAND [OPTIONS] [FILE]...
A simple but well-integrated package manager.

Defaults for the options are specified in brackets.

List of commands:
...
"

So much for the need of an external command and the use of heredoc... :-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]