5 ms·
That's the whole point of shell scripting, to take a series of minimal programs and tie them together into something that does a more complex task. There's no r
by amp108 7y ago
That's the whole point of shell scripting, to take a series of minimal programs and tie them together into something that does a more complex task. There's no reason to distrust a shell script simply because it is a script any more than there is to trust a binary simply because it's a binary.
- cholmon 7y agoSure, but relying on custom shell scripts as unix primitives can be problematic if you find yourself frequently managing/troubleshooting systems that you don't own, and you don't want to (or aren't allowed to) put those handy scripts in place. Then when you're on any given system, you forget whether you can use "f", or if you have to fall back on awk. I think it's less about not trusting custom scripts than it is about ensuring that your unix muscle memory doesn't atrophy.
- andrey_utkin 7y ago> if you find yourself frequently managing/troubleshooting systems that you don't own You start thinking about packaging.
- Galanwe 7y agoPackaging what? I would be mad at any admin that would dare to deploy his helper shell scripts like “addup” and “count” on a machine other than his laptop. And if you meant he could just have these things in his home, then it defeats the purpose of the original comment: trouble shooting and administering machines forces you to often switch user, machine, etc.
- dtoma 7y agoIf a company has recurring troubleshooting issues, eg. "we need to know which process is taking all the CPU/RAM/IO", why wouldn't they add a script when they provision their machines with puppet or whatever tool they use? Then instead of having to remember how to check all these things, they just run "find_resource_hogs.sh" and voila. It also enables other people to troubleshoot without specific knowledge. Of course you don't want to put anything in there just because it might save 10 seconds, but then https://xkcd.com/1205/ https://xkcd.com/1205/
- Galanwe 7y agoI agree 100% with you. I spend a lot of time moving around different machines, processes, configuration files, logs, etc. And I stopped maybe 10 years ago to use anything that is not available on a base system. I don’t use fancy shells, I don’t use aliases, I don’t write local shortcut scripts, etc. I just use regular bash, combine base utilities in one liners, and live with it. Maybe I loose 1s here and there when writing one liners compared to someone with a library of wrapper utilities. But that gives me an immense benefit: I am at home on any machine, any distribution, everywhere, without any configuration, with any user.
- blunte 7y agoThere's always something like Ansible (or even a lower-tech solution) to at least give you the basic toolset that helps you double or triple your performance.
- Galanwe 7y ago> that helps you double or triple your performance. Sure, in a quest of productivity, I should also use Vagrant and Packer to create docker images with a development environment so that I can run Serverless troubleshooting containers on all my machines. These scripts will surely help me triple the performance of my bash one liners. I’ve heard Eclipse has good shell completion and support for oh-my-zsh too.
- tasogare 7y agoThat’s the theory but frankly the syntax is so cumbersome, irregular and needs so many googling for "easy" things like conditional, substring, etc. that I now use a real programming language if a script needs to be anything more than a list of commands without any logic (besides variables substitution).
- tuldia 7y ago> That’s the theory but frankly the syntax is so cumbersome, irregular and needs so many googling for "easy" things like conditional, substring, etc. that I now use a real programming language if a script needs to be anything more than a list of commands without any logic (besides variables substitution). You are basically describing modern programming. Script Language (or scripting) is a programming language. And about the "real" programming language you can also trap yourself googling and installing yet another library (did you read the code?) and/or reimplementing existing tools from the unix programming environment.
- tasogare 7y agoYou are overly pedantic on a detail point that doesn’t matter: yes shell scripting is technically a programming language, but my point is that it is a terrible one worth ditching for any non trivial task. Perl was created precisely more than 3 decades ago to address this problem. Nowadays there are alternatives such as Python, Powershell or even scripting wrapper for compiled languages (such as C#) that allow to do the same job very well, with less surprising behavior and that can be refactored later more easily.
- vaingloriole 7y agoI disagree with you wholeheartedly and without condition. Not only are you discounting how much time it takes to learn how to program effectively in a real 'glue' language you are high handed in ignoring the ubiquity, working archive and efficacy of a shell script. Not to mischaracterize but I find this type of attitude most frequently in 'lead' individuals with less than 10 years experience: typically 20's and 30's in age. I'm curious if this is your case?