首页 > 解决方案 > Busybox 中是否缺少花括号支持?

问题描述

我在我的设备上使用 Busybox。当我尝试执行多目录删除时,Busybox 中包含的“rm”命令似乎忽略了我的花括号。有没有办法增加对它的支持?它破坏了一些包含大括号脚本的包,我不想在我自己的脚本中放置循环。

例子:

rm -rf /some/path/{foo,bar}

标签: gnubusybox

解决方案


这取决于您使用的外壳。Busybox 至少带有 2 个默认 shell:ash并且hush,根据您构建它的方式,您可能同时拥有这两个 shell。如果rm -rf /some/path/{foo,bar} 对您不起作用,您可能正在使用ash. 您可以检查:

$ echo $0
ash

检查您是否有hush

$ busybox hush

花括号应该适用于hush

$ mkdir /tmp/curly-test
$ cd /tmp/curly-test
$ touch foo bar
$ cd /tmp
$ ls curly-test/{foo,bar}
curly-test/bar  curly-test/foo

另请注意,作为最后的手段,您可以简单地替换/bin/shbash.


推荐阅读