bash_kernel
bash_kernel copied to clipboard
Running a cell which has Bash code with a missing delimiter causes `ValueError: Continuation prompt found - input was incomplete:` in Jupyter log

Running a cell with some missing delimiter (see screenshot above) produces the following error output in my Jupyter log, and requires interrupting the kernel to be able to continue working:
[I 2022-02-09 11:08:39.046 ServerApp] Creating new notebook in /Documents/JupyterLab
[I 2022-02-09 11:08:39.582 ServerApp] Kernel started: a8654c4f-a53d-49f5-a022-e71746be6b85
[IPKernelApp] ERROR | Exception in message handler:
Traceback (most recent call last):
File "/home/miki/.pyenv/versions/jupyterlab/lib/python3.10/site-packages/ipykernel/kernelbase.py", line 357, in dispatch_shell
await result
File "/home/miki/.pyenv/versions/jupyterlab/lib/python3.10/site-packages/ipykernel/kernelbase.py", line 647, in execute_request
reply_content = self.do_execute(
File "/home/miki/.pyenv/versions/jupyterlab/lib/python3.10/site-packages/bash_kernel/kernel.py", line 143, in do_execute
self.bashwrapper.run_command(code.rstrip(), timeout=None)
File "/home/miki/.pyenv/versions/jupyterlab/lib/python3.10/site-packages/pexpect/replwrap.py", line 107, in run_command
raise ValueError("Continuation prompt found - input was incomplete:\n"
ValueError: Continuation prompt found - input was incomplete:
echo "This string is missing a closing quote
[I 2022-02-09 11:10:40.393 ServerApp] Saving file at /Documents/JupyterLab/valueerror_continuation_prompt_found.ipynb
Missing a closing quote, parenthesis or fi, esac or done is a quite common occurrence when writing shell commands. It would be nice if bash_kernel would report the error in the cell output instead of in the Jupyter log.
Yes, it should probably catch that ValueError and send it to the user as an error message. PRs welcome.