Hi Maxim,
On Thu, 19 Dec 2024 at 16:58, Maxim Cournoyer <[email protected]> wrote:
> Hm. I agree duplication is not nice. Probably a naming issue ;-)
Arf, as we know: « There are only two hard things in Computer Science:
cache invalidation and naming things. » :-)
> According to git blame these lines were also authored by you 4 years
> ago, ha!
Ah, you got me! ;-) Bah I am consistent.
> It checks the exit status instead of the captured string output. While
> it's not that bad in that case, in general I find checking for the exit
> status a much more reliable and clean option.
Thanks for explaining. I will re-send that way. However, I still think
that’s the same from some Bash point of view…
>> Both $() and "" used in tandem makes the test sound, from my
>> understanding.
>
> Hm. Is [ "something" ] true and [ "" ] false? Apparently it is, but
> I'd argue that's not very clear, especially when there are explicit test
> operations to check for an non-empty or empty string (test -n and test
> -z).
…and welcome to weird Bash. ;-) Maybe I have misread, from my
understanding, this:
if [ "$(type -P foo)" ]
is equivalent to:
if test -n $(type -P foo)
and also equivalent to:
if type -P foo >/dev/null
And I know nothing about internals; maybe some type conversion are
avoided with the latter and some cycles are saved?
Well, it appears to me a matter of taste. :-) I find the former easier
to parse than the latter. But I also fine with the latter; let do that.
Cheers,
simon