34
Ash Vs Bash (lemmy.ca)
submitted 1 year ago by danielquinn@lemmy.ca to c/linux@lemmy.ml

[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.

you are viewing a single comment's thread
view the rest of the comments
[-] danielquinn@lemmy.ca 3 points 1 year ago

Yup, that looks like exactly what was done in Alpine:

$ docker run --rm -it alpine ls -l /usr/bin/[[
lrwxrwxrwx    1 root     root            12 Sep 28 11:18 /usr/bin/[[ -> /bin/busybox

So while the Ash itself doesn't support the [[ extension, this work-around produces the same effect. Nifty.

[-] jntesteves@lemmy.world 5 points 1 year ago

Although that link exists, that's not what is being used by default. [[ is a shell builtin in ash/busybox, so that takes precedence.

On Alpine:

❯ which [[
/usr/bin/[[

❯ command -V [[
[[ is a shell builtin
[-] danielquinn@lemmy.ca 1 points 1 year ago

Huh. So the link is unnecessary and Ash supports [[ out of the box? Good to know, thanks!

this post was submitted on 02 Nov 2023
34 points (97.2% liked)

Linux

48035 readers
742 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS