Mike Frysinger wrote:
> relying on an external program
The point is that external programs can have all sorts of undesired
side effects. For instance, if an directory is not readable (or
readable but not executable or is on $FILESYSTEM with who-knows-what
permissions or accessability problems) it can cause unexpected
errors which otherwise are treated by "standard" shell behavior:
*This* is why the ls is hackish here, not the readability.
About the readability, one can always have different opinions,
but your attack is inappropriate:
> to get a single line of readable code is better than
> multiple lines of code that attempt to do the same thing.
First, my suggestions are not "multiple lines" but only
exactly *two* lines (i.e. only one additional line):
Please compare
set -- "${ROOT}"/etc/openvpn/*/local.conf
if test -e "${1}"
with the "single line of readable code" which contains not less code,
but is only squashed into one line:
if [[ -e $(ls -1 -- "${ROOT}"/etc/openvpn/*/local.conf) ]]
Is this really so much more readable?
(The "--" can be omitted in both code pieces iff portage has a test
that ROOT does not start with "-").
And if you really want only readability, you should like even much
more my second suggestion which could also be squashed as two lines:
Exists() { test -e "${1}"; }
if Exists "${ROOT}"/etc/openvpn/*/local.conf
I would say this is *way* more readable than the complex 1-liner.
Of course, opinions may differ, but I think an unfounded attack as
> your further examples here are even worse on many levels.
is not appropriate here.
Regards
Martin