V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
mytry
V2EX  ›  程序员

curl 命令参数 `-o-` 有什么意义?

  •  
  •   mytry · 2019-05-17 11:54:46 +08:00 · 5324 次点击
    这是一个创建于 1768 天前的主题,其中的信息可能已经有所发展或是发生改变。

    看见 nodejs nvm 的安装命令: https://github.com/nvm-sh/nvm

    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
    

    or Wget:

    wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
    

    curl 的 -o 是输出到某个文件,-o- 是输出到 stdout 吗,这和不加任何参数有什么区别? wget 倒是可以理解,因为它默认是输出到文件的。

    (另外,看到很多程序远程安装都提供 curl 和 wget 两个版本,是不是有些系统默认不支持 curl 或者不好用?)

    6 条回复    2019-07-09 14:08:19 +08:00
    neroxps
        1
    neroxps  
       2019-05-17 12:05:19 +08:00
    busybox 默认只有 wget
    xiadong1994
        2
    xiadong1994  
       2019-05-17 12:11:51 +08:00
    -o-就是输出到 stdout。
    有的系统既没有 wget,也没有 curl ……
    CSM
        3
    CSM  
       2019-05-17 12:14:48 +08:00 via Android
    内容是二进制文件时,curl 会提示你为了不搞乱终端,截断了输出之类的,所以需要显式指定。
    但是输出重定向不就不会有这个提示了,所以我猜是 -o- 看起来很萌?( ̄▽ ̄)
    ly50247
        4
    ly50247  
       2019-05-17 12:15:32 +08:00
    在这里加不加 -o- 没什么区别。
    AsisA
        5
    AsisA  
       2019-05-17 17:45:20 +08:00
    应该是大写的 O 吧,大写 -O- 会输出到 stdout
    no1xsyzy
        6
    no1xsyzy  
       2019-07-09 14:08:19 +08:00
    https://github.com/curl/curl/blob/92963d612b9c5ef32d63d26c72d6fff64930eba6/src/tool_operate.c#L818

    config->terminal_binary_ok = (outfile && !strcmp(outfile, "-"));

    "-" 有区别的地方就这一个,所以应该如 #3 所说。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3889 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 10:28 · PVG 18:28 · LAX 03:28 · JFK 06:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.