Skip to content

Setting xtrace (set -x / set -o xtrace) results in exit code 1 for subsequent cells #123

@tchamberlin

Description

@tchamberlin

Setting the xtrace option (e.g. via set -x) results in an exit code of 1 for that cell, and subsequently-executed cells.

Here is the contents of the notebook:

echo foo  # exits with code 0
set -x  # exits with code 1
echo foo  # exits with code 1

And a screenshot of the same notebook:

image

As a sanity check, here's what this looks like in a "standard" bash shell (bash 5.2.9 in terminator 2.1.1):

$ echo foo; echo $?
foo
0
$ set -x; echo $?
+ echo 0
0
$ echo foo; echo $?
+ echo foo
foo
+ echo 0
0

No non-zero exit codes.

And for the sake of completeness, from $ help set:

-x Print commands and their arguments as they are executed.

Is there any known explanation for, or workaround to, this?

Environment details:

$ cat /etc/fedora-release 
Fedora release 37 (Thirty Seven)
$ python --version
Python 3.11.0
$ jupyter --version
Selected Jupyter core packages...
IPython          : 8.6.0
ipykernel        : 6.18.1
ipywidgets       : not installed
jupyter_client   : 7.4.7
jupyter_core     : 5.1.0
jupyter_server   : 1.23.3
jupyterlab       : 3.5.0
nbclient         : 0.7.0
nbconvert        : 7.2.5
nbformat         : 5.7.0
notebook         : 6.5.2
qtconsole        : not installed
traitlets        : 5.5.0
$ pip show bash_kernel | grep Version
Version: 0.8.0

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions