oclif/plugin-not-found

Plugin hides failure of command if stdin is closed

dominics opened this issue · 5 comments

When the plugin is installed, and the CLI is called with no available stdin (note: <&- is bash for "close stdin", but this also happens with e.g. < /dev/null)

$ my-cli this-does-not-exist <&-
 ›   Warning: this-does-not-exist is not a my-cli command.
Did you mean some-other-command? [y/n]:
$ echo $?
0

Then, the CLI exits with a zero (successful) exit code, even though no command was found or executed, and no answer was given to the not-found prompt.

This should instead be an error exit code.

@dominics Thank you for raising this issue. We will investigate the cause.

@dominics I'm not seeing this on the latest versions of @oclif/core (1.3.1) and plugin-not-found (2.3.1)

~/repos/oclif/plugin-not-found [main] : sf updte <&-
 ›   Warning: updte is not a sf command.

 ›   Error: command updte not found
~/repos/oclif/plugin-not-found [main] : echo $?
2

Can you try updating to those versions and seeing if this is still an issue? Thanks!

Yes, this still seems to be an issue. Circling back with a command you can run/see.

The original problem was happening on a private repository, so I've ported an open source project of mine from Oclif v1 to v2, to verify it's still happening in the latest versions, and to help with reproduction:

$ npx monofo@5.0.2 piiipeline < /dev/null
npx: installed 263 in 29.068s
 ›   Warning: piiipeline is not a monofo command.
Did you mean pipeline? [y/n]:
$ echo $?
0

This is using @oclif/core 1.3.3 and plugin-not-found 2.3.1 - right up to date.

Using the in-repo version of the run script above fails the same way (e.g. ./bin/run from within monofo, rather than npx monofo@5.0.2). so it's probably not my packaging (but could be the run script itself I guess). I'm also not using ts-node, if that matters at all.

@dominics thanks for the response. Unfortunately, I don't think this is something our team is able to prioritize right now.

However, we are more than happy to accept a PR if you want to find a solution yourself

This issue has been linked to a new work item: W-15205956