5 ms·
Shellcheck is one of those rare tools that made me a significantly better developer. In part because the more bash a dev knows the more effective they are at li
by badloginagain 8y ago
Shellcheck is one of those rare tools that made me a significantly better developer. In part because the more bash a dev knows the more effective they are at life in general, in part because it made it easy to follow rigorous coding standards- allowing me to take the quality-code mindset to less rigorous environments.
- sethrin 8y agoI wrote a short book for novices on shell usage, because it is extremely important for developers to know. Bash one-liners are usually even pretty defensible. But I dream about how the world would be if Bash were actually a good scripting language. It compares favorably to csh, and I fear that's about the best you can say for it.
- AceJohnny2 8y ago> But I dream about how the world would be if Bash were actually a good scripting language. It compares favorably to csh, and I fear that's about the best you can say for it. I finally started appreciating Perl after having to write some nontrivial Bash scripts. (My hierarchy is: default to Bash when my task is mostly running commands. If there's a bit of text-processing or regex required, Perl. If I need any hierarchical datastructures, Python)
- sethrin 8y agoI think that the simple expression of this might be that Bash is a command language, not a scripting language.
- nerdponx 8y agoYou might enjoy Zsh.
- 3rdAccount 8y agoHaha, I came to the same conclusions. Perl can do nested data structures, but it ain't easy. With Python, I did it without knowing it was a thing.
- ryl00 8y agoWhat's difficult about hierarchial data structures in Perl?
- vgy7ujm 8y agoAgreed, it's rather one of Perl's strengths.
- AceJohnny2 8y agoThe need for references.
- jonnydubowsky 8y agoI'd love to know more about the book!
- sethrin 8y agoThe focus is on usage as opposed to scripting, and it was written in a few days as a somewhat visceral reaction to seeing a single-page introduction to the shell in a coding academy. It may be that the term "booklet" is more appropriate than "book", and it is certainly the case that "wrote" in the context above should not imply "edited" or "published". However, at the moment I am between projects, and I am very happy to take your interest as a spur to complete this work. However, if you had some time to indulge, I might be able to repay your interest somewhat sooner; having other people review one's final copy is probably the next thing to a necessity.
- MaxBarraclough 8y ago> It compares favorably to csh, and I fear that's about the best you can say for it. Ha. Talk about 'damned with faint praise'. I'm not really in the Unix admin world, but can't you just bite the bullet and use a 'real scripting language' like Python? Other than for things like configure scripts, is the universality of BASH/POSIX really non-negotiable?
- jacobush 8y agoPython has versions
- MaxBarraclough 8y agoPython3 is pretty stable, no?
- jacobush 8y agoIt's starting to get there, recently, so I am hopeful Python can be a good alternative to Bash more often nowadays! There is also the cultural difference. In Python, it's so easy use pip and modules, but if you want something to replace Bash, you need to resist the temptation and only use what's in the standard library. The thing with Bash scripts is that they are often self contained and you can grab a huge snippet of it and it will work pretty much everywhere. (Exceptions of course, the script may do some fancy include or use a program not available, but you get my drift with this.) Bash has been stable a long time, and the Bourne shell compatible part of it for even longer.
- vageli 8y ago> There is also the cultural difference. In Python, it's so easy use pip and modules, but if you want something to replace Bash, you need to resist the temptation and only use what's in the standard library. I don't think it's fair to say that bash programs are not without dependencies, just that the developers (tended to be?) are more thoughtful about portability. For example I've seen scripts that use wget or fall back to curl when it's not available. I've never seen a python script fall back to urllib3 when requests wasn't available on the system.
- flukus 8y ago> In part because the more bash a dev knows the more effective they are at life in general On that note this article (https://iridakos.com/tutorials/2018/03/01/bash-programmable-completion-tutorial.html https://iridakos.com/tutorials/2018/03/01/bash-programmable-...) on bash completion scripts has been a big boon for my effectiveness recently. I've been creating simulations of our complex interactions with third party systems and the completions scripts are doing things like pulling the correct values from the database rather than having to type them in manually. I knew I'd saved a bunch of time but it really hit home yesterday when I had to explain to QA how to repeat the process and it's "open this file, change these values, save it here, open other file, set these values from previous file, save here". For me the whole thing is "cmd<tab><tab>". Does anyone have any tips on taking scripts like that and generalizing them for whole teams? At the moment they're very much built for my personal needs.
- 3rdAccount 8y agoUsually I just add the script to our wiki (Confluence/Jira) with background information and usage examples. Then I export as a PDF copy for those without access.
- cwilkes 8y agoIf you can move them over to a slackbot and direct people to a slack channel to use it. Then you get the benefit of * everyone using the latest version * a history of commands run. People can then use it as a built in FAQ and see what to do based on what others do * they don’t have to have any software installed locally Of course it doesn’t work for everything but if you can try it out.
- yAnonymous 8y ago>In part because the more bash a dev knows the more effective they are at life in general At some point, using bash isn't effective anymore. It's great and all, but an important skill is knowing when to use it and when not to.
- amelius 8y agoTotally agree. I'm using bash only for scripts that are at most (say) 10 lines long. More complicated than that, and I'm off to a real programming language.