Search code examples
gnubusybox

Is curly braces support missing in Busybox?


I am using Busybox on my device. When I try to do a multi-directory delete, it seems like my curly braces are ignored by the "rm" command included in Busybox. Is there any way to add support for it? It breaks some packages that includes scripts with curly braces and I don't want to put loops in my own scripts.

Example:

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

Solution

  • It depends on the shell you use. Busybox comes with at least 2 default shells: ash and hush and, depending on how you built it you may have both of them available. If rm -rf /some/path/{foo,bar} doesn't work for you you're probably using ash. You can check:

    $ echo $0
    ash
    

    Check if you have hush:

    $ busybox hush
    

    Curly braces should work in 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
    

    Also notice that as the last resort you can simply replace /bin/sh with bash.