5 ms·
If you're trying to put sql queries into a bash script, I beg the question to rewrite said script in a programming language. There are of course a bunch of othe
by sigmonsays 5y ago
If you're trying to put sql queries into a bash script, I beg the question to rewrite said script in a programming language. There are of course a bunch of other factors that would justify a rewrite so this isn't a hard rule.
However, having written hundreds of lines of bash gluing systems together for various CI jobs and automations, at some point you need to stop writing bash and switch to something with a richer data model and easier to maintain/test.
- 0xbadcafebee 5y agohttps://en.wikipedia.org/wiki/Begging_the_question https://en.wikipedia.org/wiki/Begging_the_question
- _russross 5y agoIn English, meaning is defined by common usage. I know the formal logic hipsters have mounted a persistent campaign to make an exception here, but the fact remains that "begging the question" means exactly what ordinary people think it means.
- gxs 5y agoWhile I agree with you in principle, I think it’s more than permissible to make this distinction on this forum given the audience, IMO, even if the person who made the comment admittedly lacked tact in their approach.
- knorker 5y agoI've spoken and written English for over three decades, and this is the first time I've seen "begging the question" be used to mean this. It's usually meant as "raises the question", but language lawyers insist it means what the wiki page said. But this is neither of those two. And if you're the only one who uses a phrase a certain way, and it means other things to everyone else, then that's actually wrong, even in a descriptive language.
- handrous 5y agoThis is one of the cases for which, when writing for a broad audience, it's best to avoid the phrase in question, in either of its senses—precisely to avoid confusion or distraction like what's happening in this thread, with the common definition, and to avoid confusing the uninitiated with its more "correct", but jargony, sense—but also to accept the common meaning in others' language without complaint (ahem).
- Cloudef 5y agoMeanwhile the static sites i generate from cronjobs with bash have been rock-solid for years (jq and sqlite are awesome!), while the ones i did in python breaks on updates or cause other headaches (not just dynamic sites). Sure if its webapp, i'd do it in react or something. Bash/shell is great once you realize it's a glue language. You avoid doing anything but pipelines, and if theres no command/tool to do something, you can write that in other language and include it in the pipeline.
- spicybright 5y agoBut if OP isn't writing hundreds of lines of glue code and their solution works well for their use case, there's not much reason to re-write anything for scale that'll never happen.
- thomashabets2 5y agoIn my opinion this is not just for scale. In my opinion anything more than a one-liner is too large of a scale for bash. More thoughts on this: https://blog.habets.se/2021/06/The-uselessness-of-bash.html https://blog.habets.se/2021/06/The-uselessness-of-bash.html Another piece of evidence is that I do many many code reviews. Not once have I reviewed bash script changes that did not have subtle bugs that would bite us in real life. Not once!
- mixedCase 5y agoDoing all my scripting in Go because some people don't care to learn bash seems like a small version of hell. If I'm using bash, I just need to glue a few tools together and I've most likely decided already that concurrency more complex than simple wait(1p) is unnecessary, and that fine-grained error handling is unimportant. If I really cared about those things, I'd probably use something like Haskell that actually improves on error handling, unlike Go, or if I'm scripting something for a specific software project, whatever that project's language is.
- thomashabets2 5y agoIt's not so much about them not knowing bash, as it takes MANY lines to do things correctly sometimes. Per the example in my blog post full of mkfifo and stuff. But sure, my choice is Go. You do haskell if it's best for you.
- solotronics 5y agoWhat language do you believe is better for DevOps / Linux systems engineering than Bash?
- literallyaduck 5y agoPowershell with its inconsistent returns, weird pipeline behavior at random, and bad default output settings is not better but like all crappy pop songs pushed by the music industry it will gain popularity. NodeJS and Python could be contenders but Bash has them beat in longevity.
- solotronics 5y agoHow is python better? If I want to say install 5 different yum packages and then do a kubernetes command the bash is pretty straightforward. With python I would have to do subprocess.call and then handle the exit codes and errors in python.
- literallyaduck 5y agoBoth Node and Python attempt an OS abstraction layer which in theory could be an advantage in practice it is a leaky abstraction. Both have many packages which could enhance scripting and even the opportunity for private repos. Installing from yum makes me believe you are using Fedora so cross platform might not be a concern for you. If running on windows is a concern Cygwin could be an opportunity. I'd say Bash, Node, Python, then PowerShell in order of advantage.
- cranekam 5y agoOnce you need concurrency or have anything but the most basic logic almost anything trumps bash. It’s possible to implement basically anything in bash, of course, but that doesn’t make it sensible. Its error handling is poor, there are too many ways to do things (eg [ vs [[ vs test), dealing with non-scalar data is a pain, it has subtle gotchas (accidentally spawning a subshell and shadowing variables), it’s cryptic (${foo#bar} and friends are cool but much harder to remember than something like .replace()), and so on. If I’m just writing small tools that wire a few basic commands together bash is fine. For anything that actually needs data to be crunched or decent error handling Python, Go, Perl (though also cryptic), C++ are, IMO, a far better choice.