5 ms·
As a sysadmin you can pry the ba(sh) scripts out of my cold dead hands. I'm not a dev, I'm not really a programmer, I'm the one who has to support all the crazy
by arca_vorago 9y ago
As a sysadmin you can pry the ba(sh) scripts out of my cold dead hands. I'm not a dev, I'm not really a programmer, I'm the one who has to support all the crazy shit you devs are throwing at the wall to see what sticks. Bash is how I get shit done.
I'm just tired of bash getting bashed everytime someone mentions shell scripting, based on what mostly seems to be bandwagon reasoning. Of course if you are writing more than $arbitrarycomplexity drop into perl, etc, but there is so much that can be done quickly, easily, and readably even for a non-programmer like myself that I think there are many benefits to using shell scripts that get far too often ignored.
Also, a perfect example of a great bash script that's over 2k loc, and I've got plenty more were that came from: https://github.com/centminmod/centminmod/blob/master/centmin.sh https://github.com/centminmod/centminmod/blob/master/centmin...
- agumonkey 9y agoDon't take this bad but when you're not a programmer it's hard to understand how 2k LoC are probably 50 LoC done wrong. It's a self fulfilling prophecy, since programmers spends their day finding abstraction to turn long and windy into concise, but for the rest of the world we're just lunatics. Now I'm not as pushy as OP, but it's far from baseless bandwagon.
- majewsky 9y ago> it's hard to understand how 2k LoC are probably 50 LoC done wrong I challenge you to reimplement the shell script that grandparent linked in 50 LOC. In fact, shell script has the chance to be a lot more succinct than other languages for a lot of administrative tasks since the invocation of other programs is a first-class citizen. For example, compare this Go snippet: cmd := exec.Command("apt", append([]string{"install"}, dependencies...)) cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr err := cmd.Run() if err != nil { fmt.Fprintln(os.Stderr, err.Error()) os.Exit(1) } to its equivalent in shell script: if ! apt install ${DEPENDENCIES[@]}; then echo "exit status: $!" >&2 exit 1 fi Or even just "apt install ${DEPENDENCIES[@]}" with "set -e". Finally, what is it with sysadmins maintaining large scripts while at the same time quipping that they are not programmers? A script is very much a program, and a scripting language is very much a programming language.
- arca_vorago 9y ago> Finally, what is it with sysadmins maintaining large scripts while at the same time quipping that they are not programmers? A script is very much a program, and a scripting language is very much a programming language. You are correct, but I mostly use this preface to let people know I don't have the detailed formal training in programming most devs do. So while I can wiggle my way around perl/python/bash/awk/sed and other "systems languages" just fine I am constantly finding out how much I don't know. I suppose in the early hacker days sense of the word most of us are programmers.
- majewsky 9y ago> I am constantly finding out how much I don't know. You think that once you have a CS degree, it's not like that anymore? If anything, that feeling gets more and more common over the years.
- agumonkey 9y agoIt would be a fun challenge, note that for instance the first part of the script is dependency check, the whole is basically `import a,b,c,d` in meaning. It's true that calling programs shortens tremendously, but every time you have to glue things together you're back to grep/sed and all the fragile bash idioms. Of course you could have standalone programs to do that, in the end it would be as having a non bash programming language in disguise
- geocar 9y ago> what is it with sysadmins maintaining large scripts while at the same time quipping that they are not programmers? We've met some programmers, and don't want to be compared to that[1]. Seriously. Programmers will embark on some massive mission that Apache and dumb CGIs can do[2] Programmers will justify their slow software by saying it's readable, or by saying that the JIRA ticket didn't specify how fast the solution needed to be. Programmers will make user interfaces that require clicking multiple times to find some bug, then require the report tediously repeat those clicks, complain that the bug report wasn't accurate (can't find a button that says "OK" when it says "Close", and there's no other buttons). Programmers will actually shit in the pool, and say it improves readability. Seriously: I have seen programmers delete perfectly working code and replace it with something broken (especially on the edge cases) and then ask the sysadmin team to wake up at 3am to restart their software every night. Code that was working fine for years. Code that wasn't even in their project. Fuck that. [1]: https://news.ycombinator.com/item?id=16155641 https://news.ycombinator.com/item?id=16155641 [2]: http://marcio.io/2015/07/handling-1-million-requests-per-minute-with-golang/ http://marcio.io/2015/07/handling-1-million-requests-per-min...