Live data from Hacker News

Pure Sh Bible

github.com

41–50 of 138 posts

Re: Pure Sh Bible

#42
post #37
post #35

Earlier quoted context omitted.

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, "bus…

A major one that I use is:

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

Re: Pure Sh Bible

#43
post #35
post #29

Earlier quoted context omitted.

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

that bash you see is actually a symlink to ash

Re: Pure Sh Bible

#44

Mildly annoyed when people constantly refer to their article as the Bible of X. For those of us who are religious, it is in poor taste.

It may be in poor taste, but from a religious person’s point of view, quite a bit of the current culture in most western nations is in quite poor taste. I understand and sympathize with your objection, but I think that those called to faith (including myself) need to make peace with secularization and do as we are taught: take the road of peace at all times, accept without condoning, approach all things with open hands, provide a better example, help when help is needed, and be willing with the courage of our convictions to testify for faith when asked (and only when asked).

Re: Pure Sh Bible

#45
If you are at this level of required complexity as in those examples, you should use a proper programming language, not shell. Half those snippets fail with spaces in the wrong place, newlines, control characters, etc.

I think all such shell "magic" should come with a huge disclaimer pointing the user at better alternatives such as perl or python. And all snippets should have the necessary caveats on horribly broken and dangerous stuff such as "if this variable contains anything other than letters, your 'eval' will summon demons" in eval "hello_$var=value" and stuff...

Re: Pure Sh Bible

#46
post #35

Earlier quoted context omitted.

Try the Windows version on frippery.org. I see it in the screen capture. https://frippery.org/busybox/index.html

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.

Re: Pure Sh Bible

#47
post #39
post #19

Earlier quoted context omitted.

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.

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.

Re: Pure Sh Bible

#48

If you are at this level of required complexity as in those examples, you should use a proper programming language, not shell. Half those snippets fail with spaces in the wrong place, newlines, control characters, etc. I think all such shell "magic" should come with a huge disclaimer pointing the user at better alternatives such as perl or python. And all snippets should have the necessary caveats on horribly broken…

Yeah, I'm a diehard bash scripter but even I know to switch to Python once the script gets above a certain size/complexity.

I should really just start with Python, but old habits and all that.

Re: Pure Sh Bible

#49
i dont know about anyone else. but since ChatGPT, my shell game is probably the one that is most levelled up.

A lot of things i would either do manually because i had forgotten shell programming, or i would have done in a seperate pyenv with 2-3 packages i can get done in about 4 minutes.

Re: Pure Sh Bible

#50
post #49

i dont know about anyone else. but since ChatGPT, my shell game is probably the one that is most levelled up. A lot of things i would either do manually because i had forgotten shell programming, or i would have done in a seperate pyenv with 2-3 packages i can get done in about 4 minutes.

Same. Shell and glue-scripts in Python. The activation energy required is now close to zero.
Post reply on HN