News for hackers. Stuff that matters.
Re:Safe ways to do things in bash by digitalsushi on Monday May 14, 2018 @09:39PM (#17070939)
Re 6: I am an /extremely/ mediocre developer but I have crafted some real 99th percentile bash skills (within my company, not globally) and I completely self-sustain myself on just that. (You're wondering how many people write bash where I am, and the answer is somewhere between 8 and 15 thousand people).

It's funny how many things that seem kind of incredible for a pure bash solution, looking back over the past 21 years doing this drivel. This year is the first I had to learn how to export all of the shell's variables and function definitions for a forked clone to run asynchronous background processing of the main thread. Bash! Bash of all things. Probably 10 seconds in any other language, but here is bash kind of hopping alongside. Callbacks, reflective programming, there's always a really awkward way in bash to do what's happening in the popular languages.

Re:Safe ways to do things in bash by koolba on Monday May 14, 2018 @09:49PM (#17070996)
> It's funny how many things that seem kind of incredible for a pure bash solution, ...

My go to example of “Bash can do whaaat?!” is the source for xip.io. A custom DNS server written in a handful of lines of Bash!

https://github.com/basecamp/xip-pdns/blob/master/bin/xip-pdn...

Re:Safe ways to do things in bash by ddtaylor on Monday May 14, 2018 @10:58PM (#17071304)
I have made a lot of DNS products and doing the same thing happening here is a few lines of code in most any language. This code, while entertaining, cannot handle very simple DNS packets because of its "compression encoding.
Re:Safe ways to do things in bash by kiallmacinnes on Tuesday May 15, 2018 @12:27AM (#17071645)
This is ran behind PowerDNS, which handles the compression prior to handing off to this code, so that shouldn't be a problem.
Re:Safe ways to do things in bash by brazzledazzle on Tuesday May 15, 2018 @04:51AM (#17072563)
Which means it’s not really doing any of the heavy lifting.
Re:Safe ways to do things in bash by xyproto on Tuesday May 15, 2018 @06:51AM (#17073019)
Which is also the case for most bash scripts, the heaving lifting is done by all the executables that are called from bash, not in native bash.
Re:Safe ways to do things in bash by opinionator1 on Tuesday May 15, 2018 @09:17AM (#17073660)
Nobody said it couldn't be done, just that it shouldn't. Fun stunt but ultimately suitable only for toys or as a gimmick.
Re:Safe ways to do things in bash by digitalsushi on Tuesday May 15, 2018 @09:36AM (#17073788)
I've developed on consumer grade routers from big vendors - Asus, linksys, netgear etc, and they are all using identical quality scripts for a large majority of the router's data processing. These scripts may not be pristine, but they are sure not always just a toy.
Re:Safe ways to do things in bash by saltcured on Tuesday May 15, 2018 @11:12AM (#17074506)
Over 20 years ago, I was home on a sick day in the middle of refactoring a build system based on Bourne shell. We could not use any of the new features of BASH but had to stick to what worked as /bin/sh across a bunch of supercomputer vendors. I was finding a lot of arcane tricks to optimize execution on those systems, some of which had improbably expensive fork-exec.

In my fevered state, I wrote some arithmetic functions to do the equivalent of `expr $a + $b` and `expr $a \* $b` without any fork-exec to external commands, just to prove to myself that it could be done. I think I abused things like $IFS, for loops, recursive function calls, and case statements to make an arbitrary-precision decimal adder function.