No need for bash scripts, custom watchdog and daemonise tools, etc.
No need for bash scripts, custom watchdog and daemonise tools, etc.
Friends don't let friends write shell scripts targeting bash.
For context: Bash is not available|installed everywhere, and has some inter-version weirdness.
Write clean, posix-compliant shell scripts (i.e. target /bin/sh commonly referred to as bourne shell) and you're in a much better position.
On Debian your script will be run by Dash, on OS X it will be run by Bash, on Ubuntu or RedHat it could be different again, but the point is, they are specifically running in POSIX mode, so that you get reliable, reproducible results across systems and even across Bash versions.
A little more verbosity on the advice might have helped. I wouldn't have properly understood you were saying without @peatmoss's reply. So without the context, your original comment just seemed like knee-jerk bash-bashing.
I've encountered many scripts written by developers on Fedora that totally fail over when run on Ubuntu specifically due to using #!/bin/sh when they really required #!/bin/bash.
I specifically said "Write clean, posix-compliant shell scripts"
Do the same developers write Java code in a .cpp file and wonder why it doesn't work? Or put <?php tags in a .erb template?
Yes, you need to test to make sure that you wrote the correct things.
If more people used #!/usr/bin/env bash, it wouldn't be that big of a deal.
If they wrote posix compatible shell scripts it wouldn't be any big deal because they'd just work.
* https://wiki.ubuntu.com/DashAsBinSh
* https://wiki.ubuntu.com/DashAsBinSh/Spec
* https://lists.debian.org/debian-release/2007/07/msg00027.htm...
Can you cite some sources here? No one knows what you're talking about.
Many people, especially Solaris and BSD folk, don't like bash scripts, and want you to write shell scripts in Bourne shell instead.
Many other people, who code on OS X and deploy on Linux, enjoy the extras bash adds, and only deploy on platforms that include bash.
Also, just because you may not know what I'm talking about, don't assume no-one else does.
https://www.freedesktop.org/software/systemd/man/systemd.ser...
There's going to be a 16.04.1 release just 3 months away from the initial LTS release; I believe it is just for that.
https://wiki.ubuntu.com/TrustyTahr/ReleaseSchedule - this schedule is for 14.04, but I believe it's been the same for quite a few years already.
For that matter, Ubuntu 14.04 is still supported for another two years, and that's still upstart.
The big deal now is that all the major distributions support the same mechanism.
AFAIUI OS X has launchd, and Solaris has OMF[1]?
... so basically the BSDs are the ones left behind?
[1] I think that is the acronym for Solaris' XML-based standardized system service files? (I don't care that they're XML. It care that they're standardized.)
Here's a "portable" script for van Smoorenburg rc that ports to 4 Linux families, complete with the sort of case statements that I described in https://news.ycombinator.com/item?id=10357589 :
* http://conman.googlecode.com/svn/trunk/etc/conman.init.in
Here's a Mewburn rc script:
* http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/etc/rc.d/...
Yes, but you cannot embed shell script directly in the job/service definition... thus making the "good path" simpler and more natural, which is a Big Deal(TM) in software usability. (As evidenced by the fact that many many upstart jobs on Ubuntu at least used "script" sections.)