【问题标题】:curl on macos Catalina not displaying response bodymacos Catalina 上的 curl 不显示响应正文
【发布时间】:2019-10-21 16:24:25
【问题描述】:

尝试使用 curl 对 https://transfer.sh 进行 curl 并且响应正文从屏幕上消失。我从终端制作了一个 gif:https://giphy.com/gifs/hvjZcaFbRPl9LbsBXg

我正在尝试运行这个 cmd,其中 test 是一个文本文件:

curl --upload-file test https://transfer.sh

对于解决方法,我使用的是内联 python 脚本,效果很好:

python -c 'import requests; print(requests.post("https://transfer.sh/", files={"upload_file": open("test","rb")}).text)'

【问题讨论】:

  • 我面临着同样的行为,但仅限于 zsh。我的意思是 bash 它按预期工作。你是不是也觉得 "curl"+"zsh" 好像是个问题? (如果是,也许问题应该重命名,包括zsh)有人知道这是curl或zsh的错误还是只是预期的“不兼容”?

标签: macos curl


【解决方案1】:

可以用 -w "\n" 修复:

curl --upload-file test -s -w "\n" https://transfer.sh

【讨论】:

    【解决方案2】:

    curl 似乎在给终端回车。尝试使用 tr 去除回车:

    curl --upload-file test https://transfer.sh | tr -d '\r'

    【讨论】:

    • 相同的行为。顺便说一句,你知道 zsh 是否这样做吗?
    猜你喜欢
    • 1970-01-01
    • 2017-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多