zoxide icon indicating copy to clipboard operation
zoxide copied to clipboard

zoxide doesn't work on ksh

Open neelchakrabrty opened this issue 1 year ago • 9 comments

Hello. I am writing a zoxide port for OpenBSD. The port installs as expected, and zoxide works as expected on supported shells. However, it doesn't work on ksh, which is what is currently blocking the port to be committed by the developers(I am not a developer). I have tried adding eval "$(zoxide init posix --hook prompt)" to my .kshrc but it didn't work. I have tried generating shell config using zoxide init but that threw an error too.
error: invalid value ksh for <SHELL> Are there any known workarounds for this issue? If not, is it possible to add support for ksh?

neelchakrabrty avatar Sep 11 '24 07:09 neelchakrabrty

I have tried adding eval "$(zoxide init posix --hook prompt)" to my .kshrc but it didn't work.

ksh is a POSIX-compliant shell, so this should work. Could you describe the exact issue?

ajeetdsouza avatar Sep 11 '24 13:09 ajeetdsouza

It was an issue on my end. I forgot to source my .kshrc

neelchakrabrty avatar Sep 12 '24 04:09 neelchakrabrty

zoxide v0.9.5 now officially supports ksh. Do try it out whenever you get the chance!

ajeetdsouza avatar Sep 13 '24 00:09 ajeetdsouza

I just tried it on OpenBSD-current.

I am getting the following error when I source .kshrc

ksh: trap: -p: unknown option
ksh: trap: bad signal DEBUG

neelchakrabrty avatar Sep 13 '24 01:09 neelchakrabrty

Which ksh are you using?

ajeetdsouza avatar Sep 13 '24 01:09 ajeetdsouza

The one that is in OpenBSD base install. https://man.openbsd.org/ksh.1

KSH v5.2.14

neelchakrabrty avatar Sep 13 '24 01:09 neelchakrabrty

Found the issue. It seems OpenBSD's ksh is lacking in some features:

The original Korn shell's DEBUG trap and the handling of ERR and EXIT traps in functions are not yet implemented.

ajeetdsouza avatar Sep 13 '24 01:09 ajeetdsouza

For the time being, the POSIX shell method works. That's good enough for me.

Thank you for helping me and adding support for KSH so quickly.

neelchakrabrty avatar Sep 13 '24 01:09 neelchakrabrty

For now I'd suggest using --hook prompt when initializing zoxide, I'll look into it once I'm able.

ajeetdsouza avatar Sep 13 '24 01:09 ajeetdsouza

Took a look at this. Unlike bash or zsh, ksh implementations generally don't have any non-POSIX features that would result in a better zoxide plugin, so I'm closing this issue.

ajeetdsouza avatar May 12 '25 01:05 ajeetdsouza