3 ms·
I could talk about this all day, but I don't have the time, so I'll just address some of your more important points. Fcron has some features that I like that I
by lobster_johnson 11y ago
I could talk about this all day, but I don't have the time, so I'll just address some of your more important points.
Fcron has some features that I like that I didn't find when I looked at it (the documentation is very poor: "dialog dyn-amically with a running fcron daemon" didn't really invite me to think that it had a job scheduling UI), but it's not sufficiently built out that I will be able to trade my current toolset for it. For example, it seems that it lacks any process isolation. Email-only reporting is not acceptable. And so on.
I agree that Fcron is a better Cron. But I also think that it's a very poor Systemd. Like Systemd, it controls the lifetime of processes; it has an overlapping feature set (job files, backing store, control UI) and if one made it complete, it would look a lot like Systemd. I'd rather have one tool do process orchestration, rather than two.
> But C programs written by people who can't be arsed are also brittle
Certainly. But it's hard to write C programs that fail for the same half-assed reasons that shell scripts do. C programs suffer from other problems. I'd much rather have a C program segfault on bad input right away than have a shell script happily continue to run because it ran some text file through tr, got a different result than it expected, stored it in a variable, passed it badly-quoted to some tool 27 lines down in the script, and triggered an impossibly obscure error message unrelated to the original cause.
But the real alternative isn't C, of course. It's one of the languages you mentioned. Ruby, Python, Erlang, Go, Nim, etc. all improve on the historical sloppiness of Unix.
> How does ... not fix all space handling problems when using bash?
There's much more to it than that, I believe.
For example, preserving quoted arguments is a nightmare. Let's say you read some file that contains command-line options. It contains something like:
-x -y --string="hello world"
You want to read that, preserving quoting, into an environment variable, which you then want to modify and pass on to another script. Turns out this is hard. Normally, quoting "$foo" works; but the moment you fiddle with it, the quoting is lost. There's a neat bash trick few people know about which exploits its array support:
#!/bin/bash
configopts=`cat configfile`
eval ARGS=($configopts)
ARGS+=("--anotherflag")
ARGS+=("$@")
./somecommand "${ARGS[@]}"
Throughout this script, $ARGS' internal token structure is preserved, even when it's manipulated. There are other ways to accomplish this, but none of them are pleasant, and this way is quite pleasant, once you get past the weirdness. But I would bet that most developers don't even know that bash has first-class array support. (If you know a better solution,
This is just one horrible corner case where a naive implementation would blow up. As I said originally, it's possible to write safe, resilient, mostly well-behaved shell scripts. But it's hard; you have to know about every possible pitfall [1] and divergent behaviour on GNU and BSD. Shell scripts implement most of their functionality through external commands, not functions, so you cannot assume much about the interface of commands. This takes time and effort. But shell scripts are easy to write, which invites sloppiness. Few people write unit tests for shell scripts. Few people use something like autoconf to sniff the runtime environment (e.g., GNU vs BSD).
As for "entire OS built on shell scripts", every Unix distro out there is built on tons of shell scripts. Even Upstart and Systemd can hardly avoid using a bit of scripting.
As for SSH, you're in a pretty good spot if you send your script using <<'EOF and disable the tty. Otherwise you run into quoting issues fast, and scripts that expect interactivity will hang. There might be some other corner cases, I forget. Controlling SSH from scripts has always been painful and brittle for me.
> [Erlang] ... difficult to run into unless you're unusually careless
Sure. But it's there. Erlang's duck typing means it's susceptible to sloppy inputs just like any other duck-typed language. It's a lot better than the shell script situation, to be sure.
[1] http://mywiki.wooledge.org/BashPitfalls http://mywiki.wooledge.org/BashPitfalls
- simoncion 11y ago> (the documentation is very poor: "dialog dyn-amically with a running fcron daemon" didn't really invite me to think that it had a job scheduling UI) I... uh.... read the documentation -rather than the second headings- and immediately understood that it had a job scheduling UI. :) I understand that we're all busy, but it does pay to take fifteen minutes or an hour every couple of weeks to sharpen the axe. > it's not sufficiently built out that I will be able to trade my current toolset for it. I never was claiming that you should. I was addressing your initial claim, mentioned a little bit later in this comment. > For example, it seems that it lacks any process isolation. Linux does that. > Email-only reporting is not acceptable. Consuming email is trivial. There are something like 349024823904 libraries and like a handful of good ones to do so in every popular language. :) > I agree that Fcron is a better Cron. But I also think that it's a very poor Systemd. Your initial assertion was that the only way to get a good cron was to implement systemd. I demonstrate that that's not true, and you counter with "Well, that cron's not systemd!"! sigh. > I'd much rather have a C program segfault on bad input right away... You and I both know that it's trivial to write a C program that does exactly the same thing that your hypothetical poorly-written bash program does. :) Bash didn't invent Heisenbugs. > It's one of the languages you mentioned. Ruby, Python, Erlang, Go, Nim, etc. all improve on the historical sloppiness of Unix. /s/Unix/Bash or sh/ and I agree with your statement. I also note that Perl (shudder) is conspicuously absent from your list. :) > There's much more to it than that, I believe. For example, preserving quoted arguments is a nightmare. Thanks for the examples! I'll go over them over the next couple of days and see what I can learn from them. :D > But I would bet that most developers don't even know that bash has first-class array support. (If you know a better solution, Did you accidentally a sentence or two? Also, the recurring theme that I've been spotting here has been "Programmers who don't know their language often write bad or broken programs in that language.". Is this not one of the larger themes of your statements? :) > Controlling SSH from scripts has always been painful and brittle for me. Sorry, this is something that I've not yet had call to do. What exactly do you mean by "controlling SSH from shell scripts"? Something like ssh user@host "someRemoteCommand $AND_A_SCRIPT_VAR_TOO" embedded in your script? (Or the equivalent here-document?) > As for "entire OS built on shell scripts", every Unix distro out there is built on tons of shell scripts. That hardly means that the entire OS is built on shell scripts. I argue that the vast majority of the shell scripts out there are to handle process startup. While this is quite important, it's important to remember that the stuff that actually gets work done in the OS is very rarely written in Bash. > Erlang's duck typing means it's susceptible to sloppy inputs just like any other duck-typed language. I see what you're saying (and agree with your final sentence), but one could just as justifiably say "C and C++'s ability to permit the programmer to override the specified type of a given variable means that such programs are susceptible to errors of sloppy logic. We should really be using Haskell to write our system management programming." ;) Anyway. Thanks for the ongoing conversation. This has been quite informative.