switch from 'which <cmd>' to 'type -P <cmd>'. A minimalistic image might have no 'which'