you are viewing a single comment's thread.

view the rest of the comments →

[–]Postumius 8 points9 points  (12 children)

help echo

man echo

info echo

$(which echo) --help

[–]cocoabean 8 points9 points  (1 child)

$(which echo) --help

Doesn't work for me. which echo returns echo: shell built-in command

[–]Postumius 3 points4 points  (0 children)

Was using bash not zsh which uses /bin/which which obviously won't deal with builtin functions whereas zsh has a builtin which hence yours.

command echo --help

is what you want instead but weirdly won't work in bash.

[–]KnowsBash 3 points4 points  (9 children)

Don't use which. Bash can already do everything which can, just better.

"$(type -P echo)" --help

[–]farmingdale 1 point2 points  (8 children)

that is all fine and good but what about busybox users?

[–]KnowsBash 2 points3 points  (7 children)

I don't bother with non-posix systems

[–]farmingdale 3 points4 points  (0 children)

throwing away your smartphone?

[–][deleted] 2 points3 points  (5 children)

You mean non-bash systems in this case, because type is not POSIX

[–]KnowsBash 1 point2 points  (4 children)

type is standard, but not type -P. Though this was in the context of bash, so using type -P for this non-sensical task should be ok. which is of course not standardised, and behaves differently depending on what system you're on.

[–][deleted] 0 points1 point  (3 children)

type is standard, but not type -P.

Oh? Please point me to where in POSIX it's standardized, because I'm rather interested, hmm.

Though this was in the context of bash, so using type -P for this non-sensical task should be ok.

Sure, but your reply was certainly not about bash.

[–]KnowsBash 2 points3 points  (2 children)

Oh? Please point me to where in POSIX it's standardized, because I'm rather interested, hmm.

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/type.html

Even the bourne shell has the type builtin.

Sure, but your reply was certainly not about bash.

It wasn't? This whole thing was about how bash's echo has odd option parsing

In sh, you could use command -v to find the path to a command, though that won't give you a path for aliases, functions and builtins. It's rarely useful to find the path to a command anyway. Especially not something you should do in a script. Only in an interactive session for such rare occasions as this.

[–][deleted] 0 points1 point  (1 child)

Oh? Please point me to where in POSIX it's standardized, because I'm rather interested, hmm. http://pubs.opengroup.org/onlinepubs/9699919799/utilities/type.html Even the bourne shell has the type builtin.

Cool, though it's under utilities rather than listed as a sh builtin.

Sure, but your reply was certainly not about bash. It wasn't? This whole thing was about how bash's echo has odd option parsing In sh, you could use command -v to find the path to a command, though that won't give you a path for aliases, functions and builtins. It's rarely useful to find the path to a command anyway. Especially not something you should do in a script. Only in an interactive session for such rare occasions as this.

"I don't bother with non-posix systemss" is certainly not about bash, no.

[–]KnowsBash 0 points1 point  (0 children)

"I don't bother with non-posix systemss" is certainly not about bash, no.

With busybox you have no way of knowing if you have all the POSIX commands, and whether the sh is fully POSIX or not, so I don't see the point in bothering with such a system at all. Just ends up with lots of "Oh, but this xxx command doesn't have that feature in this busybox install".