Repository: mwouts/jupytext

Issue:
Black has syntax error with valid iPython magic when using --pipe
To reproduce:

This occurs on `black, version 19.10b0` and 'jupytext==1.5.2'. When --sync a notebook to py:percent format using the following command:

```bash
jupytext --update-metadata '{"jupytext":{"notebook_metadata_filter":"all", "cell_metadata_filter":"-all"}, "accelerator":"GPU"}' --set-formats 'nb_python//py:percent,colabs//ipynb' --pipe black --pipe "sed s/[[:space:]]*\#[[:space:]]\%\%/\#\%\%/g"  --pipe 'isort -' --pipe-fmt 'py:percent' --sync
```

I get this error:
```bash
executing black -
error: cannot format -: Cannot parse: 73:0: !~/miniconda.sh -b -p $HOME/miniconda
```
Now I tracked down the error, and when I change the lines ipynb to use ``` !bash ~/miniconda.sh -b -p $HOME/miniconda```, it works just fine. Also the following lines also generated error:
```bash 
error: cannot format -: Cannot parse: 78:0: !. activate habitat;``` 

I had to change it to
```bash
!conda . activate
```

I also had to change:
```bash
!./test_locally_pointnav_rgbd.sh
```
to 
```bash
!bash ./test_locally_pointnav_rgbd.sh
```

TLDR: Black has issues when the first arg following '!' isn't a command, but references an executable file or another bash alias.  


Discussion:
lgtm-com[bot]: This pull request **introduces 2 alerts** when merging e6caf0801ed5627b3fbbd7ad6f8e20e71a0bf74d into 213acee31cb2d36b8ad36aa80dcd0f49ab922e48 - [view on LGTM.com](https://lgtm.com/projects/g/mwouts/jupytext/rev/pr-8bf885b60f8e276d82dc1ef072f92922c504974d)

**new alerts:**

* 2 for Wrong name for an argument in a call
Skylion007: @mwouts the lgtm alert is outside of the code I edited in my PR
lgtm-com[bot]: This pull request **introduces 2 alerts** when merging 57c0a69bf92088643ba69531b09dc75945b64537 into 213acee31cb2d36b8ad36aa80dcd0f49ab922e48 - [view on LGTM.com](https://lgtm.com/projects/g/mwouts/jupytext/rev/pr-a731e6c67f619bef09ed32304b948179bf01829d)

**new alerts:**

* 2 for Wrong name for an argument in a call
mwouts: Awesome! Thank you @Skylion007.
Indeed the issue raised by LGTM is not related to your contribution.
Let me see if I can fix that one first at #589  - I'll come back here afterwards.

Patch:
diff --git a/.github/workflows/continuous-integration-conda.yml b/.github/workflows/continuous-integration-conda.yml
index 68d356b..a16fa4f 100644
--- a/.github/workflows/continuous-integration-conda.yml
+++ b/.github/workflows/continuous-integration-conda.yml
@@ -65,7 +65,8 @@ jobs:
           conda install autopep8 --freeze-installed
           # install sphinx_gallery and matplotlib if available
           conda install sphinx-gallery --freeze-installed
-          conda install myst-parser --freeze-installed
+          # myst-parser
+          conda install 'myst-parser>=0.8' 'myst-parser<0.9' --freeze-installed
           exit 0
       - name: Conda list
         shell: pwsh
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 48398a6..8aa7fa2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@
 - Configured coverage targets in `codecov.yml`
 - Only scripts can have an encoding comment, not Markdown or R Markdown files (#576)
 - Support spaces in `--pipe` commands (#562)
+- Use `>=` and `<` rather than `~=` in the `extras_require` of `setup.py` (#589)
 
 
 1.5.2 (2020-07-21)
diff --git a/docs/faq.md b/docs/faq.md
index 7504b61..aa3f112 100644
--- a/docs/faq.md
+++ b/docs/faq.md
@@ -52,7 +52,11 @@ jupytext --update-metadata '{"jupytext": null}' path/to/notebooks/*.ipynb
 
 Certainly. Open your pre-existing scripts or Markdown files as notebooks with a click in Jupyter Notebook, and with the _Open as Notebook_ menu in JupyterLab.
 
-The text formats do not store the output cells. If you want to preserve these when you refresh the notebook, be sure to pair the text file to an `.ipynb` file.
+In Jupyter Notebook you can also create text notebooks with the _New Text Notebook_ menu.
+
+Output cells appear in the browser when you execute the notebook, but they are not written to the disk when you save the notebook.
+
+The output cells are lost when you reload the notebook - if you want to avoid this, just _pair_ the text file to an `.ipynb` file.
 
 If you want to convert text formats to notebooks programmatically, use one of
 ```bash
diff --git a/jupytext/magics.py b/jupytext/magics.py
index 858e0f8..4de898a 100644
--- a/jupytext/magics.py
+++ b/jupytext/magics.py
@@ -40,7 +40,7 @@ _MAGIC_FORCE_ESC_RE["csharp"] = re.compile(r"^(// |//)*#![a-zA-Z](.*)//\s*escape
 _MAGIC_FORCE_ESC_RE["csharp"] = re.compile(r"^(// |//)*#![a-zA-Z](.*)//\s*noescape")
 
 # Commands starting with a question or exclamation mark have to be escaped
-_PYTHON_HELP_OR_BASH_CMD = re.compile(r"^\s*(# |#)*\s*(\?|!)\s*[A-Za-z]")
+_PYTHON_HELP_OR_BASH_CMD = re.compile(r"^\s*(# |#)*\s*(\?|!)\s*[A-Za-z\.\~\$\\\/]")
 
 # A bash command not followed by an equal sign or a parenthesis is a magic command
 _PYTHON_MAGIC_CMD = re.compile(
diff --git a/setup.py b/setup.py
index 57bbe8f..f5a3c6f 100644
--- a/setup.py
+++ b/setup.py
@@ -55,7 +55,7 @@ setup(
     tests_require=["pytest"],
     install_requires=["nbformat>=4.0.0", "pyyaml", "toml", 'mock;python_version<"3"'],
     extras_require={
-        "myst": ["myst-parser~=0.8; python_version >= '3.6'"],
+        "myst": ["myst-parser>=0.8; python_version >= '3.6'", "myst-parser<0.9"],
         "toml": ["toml"],
     },
     license="MIT",


Test patch:
diff --git a/tests/test_escape_magics.py b/tests/test_escape_magics.py
index d6cec99..108e2db 100644
--- a/tests/test_escape_magics.py
+++ b/tests/test_escape_magics.py
@@ -164,6 +164,20 @@ def test_force_comment_using_contents_manager(tmpdir):
         "# ls",
         "# mv a b",
         "! mkdir tmp",
+        "!./script",
+        "! ./script",
+        "!./script args",
+        "!./script.sh args",
+        "! ./script.sh args",
+        "!~/script.sh args",
+        "! ~/script.sh args",
+        "!../script.sh $ENV $USER",
+        "! ../script.sh $ENV $USER",
+        "!$HOME/script.sh $ENV $USER",
+        "!/bin/sh $ENV $USER",
+        "! /bin/sh $ENV $USER",
+        r"! \bin\sh $ENV $USER",
+        r"!\bin\sh $ENV $USER",
         "cat",
         "cat ",
         "cat hello.txt",