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

silent failure in case of unbalanced quotes #141

Open
abbbe opened this issue Mar 27, 2024 · 5 comments
Open

silent failure in case of unbalanced quotes #141

abbbe opened this issue Mar 27, 2024 · 5 comments

Comments

@abbbe
Copy link
Contributor

abbbe commented Mar 27, 2024

The following screenshot illustrates the issue:
image

When this notebook is executed, cell#3 remains marked '[*]' while in reality it has failed silently and execution of the next cells can continue. Expected behavior - execution of cell#3 should fail with some kind of an error message.

@kdm9
Copy link
Collaborator

kdm9 commented Mar 27, 2024

ah, yes, this is basically the same root cause as #132, except we don't have a "you wrote half a string" error message yet. I must admit I am very busy at the minute so won't get a fix out very soon, but pull requests are welcome. However, it will be reasonably tricky to fix, given the bidirectional nesting of quotes, and also heredocs: these are valid: '"', "'", but these aren't: ""', "'' etc, let alone quoting, heredocs or other features of bash that allow further nesting not supported by shlex.

@kdm9 kdm9 added the confirmed label Mar 27, 2024
@abbbe
Copy link
Contributor Author

abbbe commented Mar 27, 2024

I have tested the scenario I have countered and #132. Both seem to use PS2 prompt.

On my MacOS:

bash-3.2$ bash --version
GNU bash, version 3.2.57(1)-release (arm64-apple-darwin23)
Copyright (C) 2007 Free Software Foundation, Inc.
bash-3.2$ echo '
> ^C
bash-3.2$ echo "
> ^C
bash-3.2$ echo \
> ^C
bash-3.2$ set | grep ^PS2
PS2='> '

On Debian-based system:

root@elon33:~# bash --version
GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
root@elon33:~# echo '
> ^C
root@elon33:~# echo "
> ^C
root@elon33:~# echo \
> ^C
root@elon33:~# set | grep ^PS2
PS2='> '

If you ask me, a correct way to handle this situation is to treat appearance of PS2 as a fault.
This is assuming you agree with the statement that in bash_kernel a shell command must fit inside of a single cell.

@kdm9
Copy link
Collaborator

kdm9 commented Mar 29, 2024

ah, of course, brilliant suggestion @abbbe! that should be pretty easy to detect, you're right.

@kdm9
Copy link
Collaborator

kdm9 commented May 8, 2024

This is actually a duplicate of #118

@abbbe
Copy link
Contributor Author

abbbe commented May 8, 2024

Seems to be, yes.

Just as a side node — I can’t shake the feeling all the fixes we come up with will be dirty hacks (of varying degree of dirtiness) until bash adds proper support for REPLs. Like use “\0” instead of “\n” to indicate the end of the command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants