dbcli / dbcli/mssql-cli

re.error: bad escape \e

オープン
#401 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る
area: interactive bug
主要言語
Python
スター
1.4k
フォーク
191
PR マージ指標
30日以内にマージされた PR はありません

説明

Hello,

I am using Windows 10 (version 19536.1000) and windows powershell 5.1. My database is in a docker container.

When writing `\e` in the prompt, I get the following error and get ejected from the database:

```
Traceback (most recent call last):
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\site-packages\mssqlcli\main.py", line 117, in
main()
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\site-packages\mssqlcli\main.py", line 110, in main
run_cli_with(mssqlcli_options)
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\site-packages\mssqlcli\main.py", line 55, in run_cli_with
mssqlcli.run()
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\site-packages\mssqlcli\mssql_cli.py", line 433, in run
text = self.handle_editor_command(text)
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\site-packages\mssqlcli\mssql_cli.py", line 296, in handle_editor_command
query = (special.get_editor_query(text) or
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\site-packages\mssqlcli\packages\special\commands.py", line 317, in get_editor_query
pattern = re.compile(r'(^\\\e|\\\e$)')
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\re.py", line 234, in compile
return _compile(pattern, flags)
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\re.py", line 286, in _compile
p = sre_compile.compile(pattern, flags)
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\sre_compile.py", line 764, in compile
p = sre_parse.parse(p, flags)
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\sre_parse.py", line 924, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\sre_parse.py", line 420, in _parse_sub
not nested and not items))
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\sre_parse.py", line 810, in _parse
p = _parse_sub(source, state, sub_verbose, nested + 1)
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\sre_parse.py", line 420, in _parse_sub
not nested and not items))
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\sre_parse.py", line 501, in _parse
code = _escape(source, this, state)
File "C:\Users\MTR\AppData\Local\Programs\Python\Python37\lib\sre_parse.py", line 402, in _escape
raise source.error("bad escape %s" % escape, len(escape))
re.error: bad escape \e at position 4
```

I tried setting the `$EDITOR` and `$env:EDITOR` variables, but it did not change the visible outcome.

Am I doing it wrong ? Is there a way I can use an external editor with mssql-cli ?
Also, would the external editor benefit from the autocompletion capabilities of mssql-cli ?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

トレースバックに示されているエントリポイントである、mssql_cli.py の handle_editor_command と packages/special/commands.py の get_editor_query から始めます。Docker を使用したデータベースで Windows PowerShell 上の \e プロンプトを再現し、エディターを呼び出しても re.error が発生しなくなったことと、外部エディターの動作が期待どおりであることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
docker, powershell, python
領域
cli, databases
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。