系统相关
首页 > 系统相关> > 使用python拧紧shell(和/或终端?)!

使用python拧紧shell(和/或终端?)!

作者:互联网

问题

只需打开和关闭Python子shell就可以拧紧我的shell(或者可能是终端?).它似乎删除了shell打印我输入的任何文本的能力,包括输入命令后的换行符.

python3.4,python2.7和python2.6会出现问题,但python2.5不会出现问题.

它之前从未发生过(我注意到了),而且我使用的其他软件包(VIM,Emacs等)也没有发生过.

我已经确认使用Apple的标准终端(版本2.2.3 [303.2]),iTerm2(版本2.1.1)和XTerm(269).

有趣的是,它打破了bash,但不是zsh或csh.

示例行为

为了演示,我执行以下操作($SHELL是/ bin / bash):

>运行哪个python3.4.
>运行python3.4.
>按一下Return键,然后在Python shell中输入exit().
>再次命中两次.
>输入python3.4 –version.

以下是我所安装的一些Python主要版本的内容:

Python3.4 – 有问题

myself@localhost:~$which python3.4
python3.4 is /opt/local/bin/python3.4
python3.4 is /opt/local/bin/python3.4
myself@localhost:~$python3.4
Python 3.4.3 (default, Aug 24 2015, 17:25:38)
[GCC 4.2.1 Compatible Apple Clang 3.0 (tags/Apple/clang-211.12)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
>>> myself@localhost:~$myself@localhost:~$myself@localhost:~$Python 3.4.3
myself@localhost:~$

Python2.7 – 有问题

myself@localhost:~$which python2.7
python2.7 is /opt/local/bin/python2.7
python2.7 is /usr/local/bin/python2.7
python2.7 is /usr/bin/python2.7
python2.7 is /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
python2.7 is /usr/bin/python2.7
python2.7 is /usr/local/bin/python2.7
python2.7 is /opt/local/bin/python2.7
myself@localhost:~$python2.7
Python 2.7.10 (default, Aug 24 2015, 11:54:49)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
>>> myself@localhost:~$myself@localhost:~$myself@localhost:~$Python 2.7.10
myself@localhost:~$

Python2.6 – 有问题

myself@localhost:~$which python2.6
python2.6 is /opt/local/bin/python2.6
python2.6 is /usr/bin/python2.6
python2.6 is /usr/bin/python2.6
python2.6 is /opt/local/bin/python2.6
myself@localhost:~$python2.6
Python 2.6.9 (unknown, Aug 24 2015, 17:53:21)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
>>> myself@localhost:~$myself@localhost:~$myself@localhost:~$Python 2.6.9
myself@localhost:~$

Python2.5 – 它的工作原理!

myself@localhost:~$which python2.5
python2.5 is /usr/bin/python2.5
python2.5 is /usr/bin/python2.5
myself@localhost:~$python2.5
Python 2.5.6 (r256:88840, Jul 31 2011, 19:30:45)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
myself@localhost:~$
myself@localhost:~$
myself@localhost:~$python2.5 --version
Python 2.5.6
myself@localhost:~$

在zsh或csh中运行它似乎工作正常:

岩组

myself@localhost:~$zsh
localhost% which python3.4
/opt/local/bin/python3.4
localhost%
localhost% python3.4
Python 3.4.3 (default, Aug 24 2015, 17:25:38)
[GCC 4.2.1 Compatible Apple Clang 3.0 (tags/Apple/clang-211.12)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
>>> %                                                                           
ra%
ra%
ra% python3.4 --version
Python 3.4.3
localhost% exit
myself@localhost:~$

CSH

myself@localhost:~$csh
Running csh
[localhost:~] myself% which python3.4
/opt/local/bin/python3.4
[localhost:~] myself% python3.4
Python 3.4.3 (default, Aug 24 2015, 17:25:38)
[GCC 4.2.1 Compatible Apple Clang 3.0 (tags/Apple/clang-211.12)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> exit()
>>> [localhost:~] myself%
[localhost:~] myself%
[localhost:~] myself% python3.4 --version
Python 3.4.3
[localhost:~] myself% exit
exit

到目前为止我的想法:

三个终端的行为似乎相同的事实使我认为这不是一个终端问题.

它在Zsh和Csh中工作但在Bash中不工作这一事实使我认为这是一个shell问题.

断开的版本(3.4,2.7,2.6)都安装在/ opt / local / bin /(MacPorts的常用安装位置)下,但工作的版本(2.5)安装在/usr/bin /下,make我想知道最近的一些MacPorts更新(可能在2015年8月24日之前推迟了20天??)可能已经破坏了使Python和Bash无法协同工作的东西!

解决方法:

近期Macports版本的python似乎存在问题,请参阅此bug

解决方法是安装pyXX-readline(py35-readline只针对这个bug生成)

另一个是安装python添加readline变体

标签:python,bash,terminal,command-line,macports
来源: https://codeday.me/bug/20190817/1679913.html