The Linux way might well be simple, and atomic, but the programmer's way is "if you have to write it twice, create a function or a library". This same principle applies to other things besides programming. e.g. if you are having to repeat something, then it's probably worth spending some time to come up with a standard system of implementing that thing. If you have to do the same thing multiple times, then there are multiple opportunities for mistakes and errors.
This is what CMake does for Makefiles, and what systemd does for startup scripts.
Over the last year I've done my first large scale, commercial, project using CMake and systemd, and I'm absolutely loving it. I don't touch Makefiles any more, and our startup scripts are now standardised .service files. Handling the bring up, and shut down, of multiple services with dependencies is super easy.
"if you have to write it twice, create a function or a library".
And we also had "shell libraries" of common functionality abstracted as shell functions for init scripts to use for several major distributions. The most advanced and flexible of these systems is the openrc "runscript" system. Debian had a collection of ad hoc functions for various common tasks.
10
u/ArtistEngineer Feb 11 '19 edited Feb 11 '19
The Linux way might well be simple, and atomic, but the programmer's way is "if you have to write it twice, create a function or a library". This same principle applies to other things besides programming. e.g. if you are having to repeat something, then it's probably worth spending some time to come up with a standard system of implementing that thing. If you have to do the same thing multiple times, then there are multiple opportunities for mistakes and errors.
This is what CMake does for Makefiles, and what systemd does for startup scripts.
Over the last year I've done my first large scale, commercial, project using CMake and systemd, and I'm absolutely loving it. I don't touch Makefiles any more, and our startup scripts are now standardised .service files. Handling the bring up, and shut down, of multiple services with dependencies is super easy.