Hacker News new | past | comments | ask | show | jobs | submit login

You can use command -v in any POSIX compliant shell. csh is not POSIX compliant. Your list of shells in inexhaustive to the point of being almost misleading. bash and zsh are "heavy-weight" shells, a lot of lightweight shells also support command.

If you're specifying your shebang as #!/bin/sh then you should not assume you have access to functions like type or binaries like which, but you can generally assume you have access to the command built-in.




> If you're specifying your shebang as #!/bin/sh then you should not assume you have access to functions like type

'type' is actually POSIX though. bash does extend it.

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/t...


Well the point is that it's a shell component, so it's not available from anything other than a shell which is undesirable.

I understand Bourne style (POSIX) shells have the vast majority of the market, but the point is breaking other environments. "command -v" is not available everywhere so it is not a viable replacement for /usr/bin/which.


"which" is also not available everywhere, that's how I know about "command -v".




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: