Hacker News new | ask | show | jobs
by wahern 1695 days ago
If you're parsing the output of `command -v`, you're doing it wrong:

  if command -v foo >/dev/null; then
    foo ...
  else
    bar
  fi
From shell scripts it doesn't matter if foo is an alias because if it is an alias, it's one that the script created itself.

For interactive use, just go ahead and use which if that's what you like. Most people will be using bash or z-shell or whatever, and portability isn't a concern.

Interactive shell usage and shell scripting are quite distinct. Yes, there's a huge overlap, but as in any other language, when you're writing a properly structured program (not a one-off or hack), you're expected (for good reasons) to follow more consistent rules and conventions.