direnv / direnv

unclutter your .profile
http://direnv.net
MIT License
12.56k stars 641 forks source link

`has rvm` always returns true #1008

Open ziadsawalha opened 2 years ago

ziadsawalha commented 2 years ago

Describe the bug has rvm always returns true because stdlib defines rvm()

To Reproduce On a machine without rvm installed, the following .envrc says ""✅ 'rvm' is detected":

if has rvm; then
  echo "✅ 'rvm' is detected"
else
  echo "❌ 'rvm' not detected"
fi

Expected behavior has rvm should not return true (or document an alternative method to detect if rvm is available)

Environment

Additional context Add any other context about the problem here.

zimbatm commented 2 years ago

Yes, it's unfortunate. I should change the has() definition to type -p "$1" >/dev/null so it only returns true when there is a command. But it would break back-compat and we don't break back-compa.

The best is to replace the rvm check with if type -p rvm >/dev/null; then ...