vscode-debug-leetcode icon indicating copy to clipboard operation
vscode-debug-leetcode copied to clipboard

"\n" become "\\n" raise a parameters parsing error in mac os zsh commandline

Open Interesting6 opened this issue 3 years ago • 1 comments

🐛 Bug Report

when the input occupied more than one line, all input lines will transform into one line connected by "\n" as a sys.stdin. And then that converts to a shell command. However, the \n in command turns out to be \\n in macOS zsh environment, which cause a Parameters parsing error.

当输入为多行时,输入会被转化为一行以"\n"连接的字符串,但在debug时,在macOS的zsh中,\n会被转化为\\n,导致了参数解析错误。

Expected behavior

Normal

Extension Output

cd /Users/treamy/Codes/Algorithms/LeetCode ; /usr/bin/env /usr/local/bin/python3 /Users/treamy/.vscode/extensions/ms-python.python-2021.2.582707922/pythonFiles/lib/python/debugpy/launcher 49611 -- "/Users/treamy/Library/Application Support/Code/User/globalStorage/wangtao0101.debug-leetcode/python3problem236.py" /Users/treamy/Codes/Algorithms/LeetCode/236. 二叉树的最近公共祖先.py [3,5,1,6,2,0,8,null,null,7,4]\\n5\\n1 lowestCommonAncestor TreeNode,TreeNode,TreeNode TreeNode 236 52013

Guidance: Press Ctrl+Shift+U, and toggle the channel to Debug LeetCode.

Your Environment

  • python 3.6.5
  • os: macOS
  • extension settings:
  • nodejs version:
  • vscode version: 1.52.1
  • extension version: 0.2.2

Interesting6 avatar Mar 07 '21 05:03 Interesting6

Maybe the error is not caused by zsh escape mechanism. For example, the input is: [3,5,1,6,2,0,8,null,null,7,4]\n5\n1

But by 5 and 1, they are both a tree node, in leecode question 236.

I see the source code, it is essential to use a list-like object to construct a tree node, instead of an integer.

So I just change the input to: [3,5,1,6,2,0,8,null,null,7,4]\n[5]\n[1] which works well.

Interesting6 avatar Mar 07 '21 06:03 Interesting6