Py学习  »  Git

为什么当stdout和stderr都被重定向时git仍然打印到屏幕上?

Leonardo.Z • 5 年前 • 1808 次点击  

我想禁用在我的CI系统中使用的git push命令的输出,该命令可能会泄漏敏感信息。

命令是:

git --quiet push > /dev/null 2>&1

所以它不应该在屏幕上打印任何东西。但它仍然有指纹 Password for 'https://xxxx@github.com': 当身份验证失败时。

更新: 虽然我不确定,但我想git打电话来了 getpass() 或者类似的东西 /dev/tty 直接的。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/52636
 
1808 次点击  
文章 [ 2 ]  |  最新文章 5 年前
iBug
Reply   •   1 楼
iBug    6 年前

Git显式打开 /dev/tty 供阅读 写入,用于密码提示。

/开发/tty 大约在1979年被添加到Unix,允许程序获取控制终端的文件描述符,因此当stdin被占用以及stdout和stderr都被重定向时,用户输入成为可能。

How does less take data from stdin while still be able to read commands from user?

phd
Reply   •   2 楼
phd    6 年前

为了防止密钥登录和解决重定向问题,密码提示通过 /dev/tty . 看看Python的 getpass .