comma icon indicating copy to clipboard operation
comma copied to clipboard

Add command-not-found handler

Open Pandapip1 opened this issue 1 year ago • 1 comments

Fixes #84

~~WIP; untested~~

Pandapip1 avatar Sep 01 '24 00:09 Pandapip1

Just tested, it works!

Pandapip1 avatar Sep 01 '24 01:09 Pandapip1

Bump, CC maintainers @Artturin @burke @DavHau

Pandapip1 avatar Jul 02 '25 14:07 Pandapip1

If a script is executing a missing binary, will this lead the script to be stuck at an interactive comma prompt?

DavHau avatar Jul 08 '25 03:07 DavHau

I believe comma only prompts in interactive mode, so yes, if the user is the one that invoked the script, and no otherwise. I could be wrong though, I haven't tried it. But this seems like the correct behavior to me and if it isn't I'll see what it takes to change it.

Regardless, before I switched to the branch from my other PR (https://github.com/nix-community/comma/pull/100, which is arguably more important and which I would prefer you prioritize reviewing over this PR) due to configuration changes, I was using this and it worked just fine (and was a pretty cool party trick).

Pandapip1 avatar Jul 08 '25 12:07 Pandapip1

If a script is executing a missing binary, will this lead the script to be stuck at an interactive comma prompt?

command-not-found handlers are only used in interactive shells

$ source src/command-not-found.sh
$ bash test.sh
test.sh: line 1: hello: command not found
$ zsh test.sh
test.sh:1: command not found: hello
$ whereis hello
hello:
$ hello
Hello, world!

Artturin avatar Jul 15 '25 16:07 Artturin

I added --ask which I think will make it safer to use the handler.

Artturin avatar Jul 15 '25 17:07 Artturin

Thanks for clearing the merge conflict too

Pandapip1 avatar Jul 15 '25 20:07 Pandapip1

Renamed file to comma-command-not-found.sh

Artturin avatar Jul 18 '25 09:07 Artturin

Thanks

Artturin avatar Jul 18 '25 09:07 Artturin