https://bugs.openldap.org/show_bug.cgi?id=9209
--- Comment #14 from Ryan Tandy ryan@openldap.org --- (In reply to Howard Chu from comment #13)
Sounds like a ridiculously broken "which". That test is checking the exit status of which, and it should be non-zero if the command wasn't found.
Unfortunately so:
ryan@sol10:~$ which dsadm no dsadm in /usr/xpg6/bin /usr/sfw/bin /usr/ccs/bin /usr/bin /opt/csw/bin ryan@sol10:~$ echo $? 0
/usr/bin/which on the most recent release of Solaris 10.
It's actually a csh script... you can see the whole thing at https://unix.stackexchange.com/a/408550
I tried Quanah's suggestion of 'command -v'... that one seems to work on every platform I've touched lately. Shellcheck recommends it, too.