Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pulsar-shell CTRL-C should be interpreted as cancel the current command and should not exit the shell #19218

Closed
2 tasks done
pgier opened this issue Jan 12, 2023 · 4 comments
Closed
2 tasks done
Labels
type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages

Comments

@pgier
Copy link
Contributor

pgier commented Jan 12, 2023

Search before asking

  • I searched in the issues and found nothing similar.

Motivation

When running pulsar-shell, CTRL-C should be used to cancel the current pulsar command instead of a full exit of the program. This would make the behavior more similar to bash and the python shell.

For example, let's say I mistype a command.

> admin topics list pblic/default

Then I want to cancel the current pulsar command, but still stay in the pulsar-shell.

Solution

Catch the CTRL-C and just cancel the current pulsar command instead of exiting completely.

Alternatives

No response

Anything else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@pgier pgier added the type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages label Jan 12, 2023
@lhotari
Copy link
Member

lhotari commented Jan 17, 2023

There might be technical limitations in intercepting CTRL-C. I remember facing this problem with Grails shell and Gradle continuous build input many years ago. Another possibility is to assign a different hot key for cancelling the current command, for example CTRL-D.

@nicoloboschi
Copy link
Contributor

I fixed it here: #18615

I noticed that actually in the tarball isn't working (using 2.11.0) but within the docker container it works correctly

docker run -v $HOME/.pulsar-shell:/pulsar/.pulsar-shell --rm -it apachepulsar/pulsar:2.11.0 bin/pulsar-shell

I'll investigate more

@nicoloboschi
Copy link
Contributor

I was using a wrong artifact. It works fine also with the artifact here: https://pulsar.apache.org/download/

Have you tried with a command that hangs ? For example, with your command I get

default(localhost)> admin topics list pblic/default
^CException in thread "SIGINT handler" org.apache.pulsar.shell.PulsarShell$InterruptShellException
	at org.apache.pulsar.shell.PulsarShell.lambda$run$2(PulsarShell.java:230)
	at org.jline.terminal.impl.AbstractTerminal.raise(AbstractTerminal.java:89)
	at org.jline.terminal.impl.PosixSysTerminal.lambda$handle$1(PosixSysTerminal.java:65)
	at org.jline.utils.Signals.lambda$register$1(Signals.java:53)
	at jdk.proxy2/jdk.proxy2.$Proxy3.handle(Unknown Source)
	at jdk.unsupported/sun.misc.Signal$InternalMiscHandler.handle(Signal.java:198)
	at java.base/jdk.internal.misc.Signal$1.run(Signal.java:219)
	at java.base/java.lang.Thread.run(Thread.java:833)
HTTP 404 Not Found

Reason: HTTP 404 Not Found

We could hide that exception but it works for me

@pgier
Copy link
Contributor Author

pgier commented Jan 17, 2023

Ah sorry, I didn't search well enough for existing issues. I wasn't using the latest master when I noticed the issue, and didn't realize this is already fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

No branches or pull requests

3 participants