[For reference, I’m talking about Ash in Alpine Linux here, which is part of BusyBox.]

I thought I knew the big differences, but it turns out I’ve had false assumptions for years. Ash does support [[ double square brackets ]] and (as best I can tell) all of Bash’s logical trickery inside them. It also supports ${VARIABLE_SUBSTRINGS:5:12}` which was another surprise.

At this stage, the only things I’ve found that Bash can do that Ash can’t are:

  • Arrays, which Bash doesn’t seem to do well anyway
  • Brace expansion, which is awesome but I can live without it.

What else is there? Did Ash used to be more limited? The double square bracket thing really surprised me.

  • @suprjami
    link
    English
    15
    edit-2
    1 year ago

    What have you found bad about bash arrays? I have some simple usage of those (in bash) and they work fine.

    • Daniel QuinnOP
      link
      fedilink
      English
      81 year ago

      As far as I’ve seen, they don’t provide any advantage over a string with spaces, which doesn’t work well either when you’ve got values with spaces:

      not_what_you_think=( "a b" "c" "d" )
      for sneaky in ${not_what_you_think[@]}; do
        echo "This is sneaky: ${sneaky}"
      done
      
      This is sneaky: a
      This is sneaky: b
      This is sneaky: c
      This is sneaky: d
      
        • Daniel QuinnOP
          link
          fedilink
          English
          41 year ago

          Aaaaah! Thank you kind stranger. It never would have occurred to me to quote an array!

          • @suprjami
            link
            English
            111 year ago

            If you run your scripts through https://shellcheck.net it’ll pick up things like this. Also available as a Linux package for offline use.