Am 31.07.20 um 03:29 schrieb Matias Fonzo:
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...
:-)
Well, you've just introduced a subtle way to shoot yourself in the foot
because now, every double quote that ever enters that help text better
be escaped with a backslash.
Using a heredoc – and that would mean using cat(1) – would avoid this
problem entirely.
So, let me repeat:
1. Speed is not of importance for printing help text. Therefore,
using
an external command – cat(1), which is part of POSIX – is fine.
After all, making use of external commands is largely what Unix
shells are built for.
2. Heredocs are safe because they are interpreted as literal strings
entirely (using a single-quoted delimiter).
3. printf is not safe for this.
So, I would really go with cat(1) and a heredoc. It's less code and it
is actually more reliable than the current solution.