Live data from Hacker News

Pure Bash Bible

github.com

11–20 of 258 posts

Re: Pure Bash Bible

#16

While this is interesting I see doing anything but launching programs with simple text-substituted arguments as too much for bash or sh. Run shellcheck on some of your own code, or the code of even a simple project to see how hard it is to really use bash. Why I think people gravitate towards it is because languages such as python add too much pomp to launching a shell process. A language like perl is usually easier…

I don’t think it’s pomp. Once I learned Unix pipes and the tools for manipulating data (sed awk cut etc), it just became much faster and easier than writing python scripts that do the same thing. You can literally connect the output of one process to the input of another with a single character. It’s much more complex in python.

It also tends to be very portable.

Re: Pure Bash Bible

#17

While this is interesting I see doing anything but launching programs with simple text-substituted arguments as too much for bash or sh. Run shellcheck on some of your own code, or the code of even a simple project to see how hard it is to really use bash. Why I think people gravitate towards it is because languages such as python add too much pomp to launching a shell process. A language like perl is usually easier…

Yes - and no. I find the shell is a useful glue language for procedural tasks (do this, run P1, then P2, and if blah) which can/had better be logically simple but rather long and heavy on the system interaction side.

For these, being able to avoid the various $(echo... |sed) can be refreshing. Beside, the book makes for a nice repository of techniques.

Re: Pure Bash Bible

#18

Didn't realize at first that "pure" refers to features available in bash without calling out to external processes, when I would've thought purism in this context should refer to avoiding bashisms and writing portable (ksh, POSIX shell) scripts.

I understand your concerns about bash features and POSIX compatibility. The bash bible was written specifically to document the shell extensions bash implements.

My focus for the past few months has been writing a Linux distribution (and its package manager/tooling) in POSIX sh.

I've learned a lot of tricks and I'm very tempted to write a second "bible" with snippets that are supported in all POSIX shells.

(I created the bash bible).

Re: Pure Bash Bible

#20

no mention of /dev/tcp?! yes, it looks like a device node in /dev, but it's really a pure bashism for opening tcp connections to arbitrary hosts and ports

I've been meaning to get around to it. I hadn't messed around with /dev/tcp prior to writing this bible.

I've since implemented a very bare-bones and very featureless IRC client using /dev/tcp and bash.

https://github.com/dylanaraps/birch

I will get around to it eventually. The one hurdle I want to get over before writing a piece about it is the handling of binary data using bash.

This is something a little tricky to do with bash but it'd allow for a 'wget'/'curl' like program without the use of anything external to the shell (no HTTPS of course).

I want to really understand the feature before I write about it though in the meantime I could just write a reference to the syntax/basic usage. :)

Post reply on HN