Hacker News new | ask | show | jobs
by vlisivka 5302 days ago
I wrote large bunch of software in shell, so I have habit to use strict mode ("set -ue"), so shell scripts are much safer.

I write scripts like large programs from scratch: decomposition, error handling, proper logging, unit testing, packaging, etc.

I wrote my own library with few useful modules, which is designed for strict mode (bash-modules on assembla), which I recommend to use even for trivial programs.

I have no problems with bash.

2 comments

Why did you do all those things? Did you have to use bash for all that software? Were you concerned about portability? Do you just dislike python?

I have no trouble understanding how complex programs can be written in bash, but I have never understood why.

Because I can. Sometimes - yes, sometimes - no, but why not? No, I am fine with Linux. Yes, I dislike python.

I hope, it is temporary problem. ;-)

This is all good, until you want your program to be really large and/or use some serious external libraries which bash lacks. Or, if you need to attach some kind of non-CLI UI to it (GUI or web), or (heavens forbid) if you need to port it to windows. Then all your plans crash and burn, and you either suck it up and port the app to Python/Perl/Ruby/C++/whatever, or just keep building an un-maintainable mess. And don't forget someone else will probably have to maintain it at some point.
It is hard to write really large and complex programs in bash, so scripts stay small, which is good thing.

In my scripts, I declare and describe command line interface of each script, so it is not hard to rewrite script in an other language when necessary. About 5% of my shell scripts were rewritten in an other language (Perl, Java, C). I had no problem with that.

Other developers and admins are happy with my software, I even got some internal awards.

My documentation/code ratio is about 7/4 (7 lines of comments and documentation per 4 lines of code), so it is easy to catch design errors - they are hard to describe in documentation in most cases. :-)

I am avoiding debugger as much as I can (lack of builtin debugger in bash helps me a lot :-)), so my software handles errors in most cases and error messages are _very_ descriptive.

I have no problems with bash, perl, C, Java, JavaScript, etc.