Commands starting with '-' can appear to be options and need quoting
wscott opened this issue · comments
Wayne Scott commented
$ -h
Usage: brew which-formula [--explain] command [...]
Prints the formula(e) which provides the given command.
--explain Output explanation of how to get 'cmd' by
installing one of the providing formulae.
-d, --debug Display any debugging information.
-q, --quiet Make some output more quiet.
-v, --verbose Make some output more verbose.
-h, --help Show this message.
Clearly we are running "brew which-formula $BADCMD" and -h gets passed to brew.
I tried this test:
$ brew which-formula -- -h
but that command appears to just hang so there are so other changes needed and it fell below the threshold where I have time to try putting together a patch.
But I figured I should at least make a bug report.
Rylan Polster commented
Thanks for reporting. You're exactly right about what's happening, here. I think the proper thing to do in this case is to not even try to pass to brew which-formula
and just fail with the standard "not found" message.