shell - 当作为 sh 启动时,Zsh 不执行大括号扩展?

标签 shell sh zsh brace-expansion

Zsh 不执行大括号扩展,但仅在使用 /bin/sh 链接调用时才执行。

$ /bin/sh --version
zsh 5.8 (x86_64-apple-darwin20.0)
$ zsh --version
zsh 5.8 (x86_64-apple-darwin20.0)
$ /bin/sh -c "echo {1..3}"
{1..3}
$ zsh -c "echo {1..3}"
1 2 3

发生什么事了?

最佳答案

Brace expansion不是传统 (POSIX) shell 的功能。它特定于 bash 和 zsh。

当作为 /bin/sh 调用时,bash 和 zsh 的行为类似于 POSIX shell,这就是大括号扩展不起作用的原因。

关于shell - 当作为 sh 启动时,Zsh 不执行大括号扩展?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65605332/

相关文章:

bash - Ansi 扩展颜色索引中颜色的 RGB 值 (17-255)

c++ - 编写一个可以嵌入其他应用程序并作为单独进程运行的 shell

linux - linux中从目录读取文件的顺序

bash - 在 Ubuntu 18.04 上使用 bash 编写 "sudo apt upgrade"脚本时,如何自动绕过 "package configuration"屏幕?

bash - OS X bash 脚本 WHILE 循环中的多个条件

customization - Oh My Zsh 使用一个别名的多个命令

linux - 无法打印进程的PID

linux - 如何安装多个 cron 作业?

bash - 如何更改 shell/bash 脚本中的 argv[0] 值?

node.js - zsh:找不到命令:grunt-init