No whichcraft
Replace all uses of which
with the standard built-in command -v
, see http://mywiki.wooledge.org/BashFAQ/081.
Also remove a few instances altogether: there's no need to look up a command's path just to run it normally, let the shell do its job.
Edited by Naïm Favier