出现"-bash:错误替换:无结束`)'"的shell错误 [英] shell error with "-bash: bad substitution: no closing `)'"

查看:151
本文介绍了出现"-bash:错误替换:无结束`)'"的shell错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个脚本(只需将其复制并粘贴到外壳中即可)

I have this script (just copy and paste it into shell)

perl -c <(cat <<'EOF'
#!/usr/bin/perl
while( @mylist>1){
if($i > $initnum) {$i--;}
   {splice( @mylist,1);}
}
EOF
)

在一台linux机器上,我得到了/dev/fd/63 syntax OK输出,没关系.但是在Macbook终端上,我看到了

On one linux machine, I got /dev/fd/63 syntax OK output, which is ok. But on macbook terminal, I saw this

$ perl -c <(cat <<'EOF'
> #!/usr/bin/perl
> while( @mylist>1){
> if($i > $initnum) {$i--;}
>    {splice( @mylist,1);}
> }
> EOF
> )
-bash: bad substitution: no closing `)' in <(cat <<'EOF'
#!/usr/bin/perl
while( @mylist>1){
if($i > $initnum) {$i--;}
   splice( @mylist
}
EOF
)

我的问题是为什么这样的错误.理想情况下,如何在Mac上进行修复.

My question is why such error. And ideally how to fix it on mac.

推荐答案

这是bash 3.2中的解析器错误,但是您的示例是一个简单的此处文档的折磨:

It's a parser bug in bash 3.2, but your example is a quite torturous replacement for a simple here document:

perl -c <<'EOF'
#!/usr/bin/perl
while( @mylist>1){
if($i > $initnum) {$i--;}
   {splice( @mylist,1);}
}
EOF

默认情况下,Apple似乎不太可能会发布新版本的bash,所以最好的选择是自己安装一个(通过自制软件.

It does not seem likely that Apple will ever ship a newer version of bash by default, so your best bet is to install one yourself (via Homebrew, for example).

这篇关于出现"-bash:错误替换:无结束`)'"的shell错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆