Hacker News new | past | comments | ask | show | jobs | submit login

I like busybox bash (especially on Windows) which is very much not bash.

Busybox bash does not implement arrays, for starters, which is a deal breaker for many scripts.

The Windows kernel forks processes about 10x slower than Linux, so these tricks have real performance value for POSIX-family shells running there.




As far as I can tell, there is no busybox bash.

busybox's built-in shell is ash. There are options to enable a few bash-compatible extensions, but there is no "bash" applet.


Try the Windows version on frippery.org.

I see it in the screen capture.

https://frippery.org/busybox/index.html


There's an option to install the "bash" applet as a link to either ash or hush, the two shells that busybox comes with. Turns out that a large number of "bash scripts" use no bash-specific features in spite of using "bash" in the #!, or only a few bash-specific features like [[ ]].

It's disabled by default, and arguably not a good idea to enable it because compatibility is not great as you found out. Either way, "busybox bash" doesn't exist: only the option to alias ash or hush to bash.


A major one that I use is:

  ${var//findpattern/replace}
It turns out that busybox equates [[ to [ in the source, sidestepping the differences.


that bash you see is actually a symlink to ash


Did you download the busybox64.exe binary and execute it?

I'm confident that it is presented. I use this to spray SQL to dozens of databases.


The bash you're seeing is a symlink to busybox, as are all busybox applets.

You can configure busybox to install an applet named "bash", but it's not a full bash shell. It's basically busybox ash, with maybe a few bash-specific extensions implemented. For example, it doesn't support arrays; `arr=(10 20)` will give you a syntax error.

In a default configuration, there is no "bash" applet. You can optionally configure busybox to alias "bash" to either "ash" or "hush" (and likewise for "sh"). This allows the use of "#!/bin/bash" scripts, but only if they don't use bash-specific features not supported by busybox.


You can implement arrays for POSIX shell in POSIX shell by changing the input separator to new line, and writing some simple helper functions to search for it. It’s not the prettiest solution but works for many use cases of arrays in shell scripts.


There are much more practical ways to iterate over a list than that in dash.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: