Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

"It's got to much code, a shell should just execute shellscript not handle input"

Honestly, I'd sooner go the other way.



sort by: page size:

There are so many awful things about shell scripting. It's always so difficult to do simple things with it.

  > A lot developers just choose shell(sh, bash, ...) scripts for such tasks,
  > by using < to redirect input, > to redirect output and '|' to pipe outputs.
  > In my experience, this is the only good parts of shell script.
If you try to use shell as a general purpose programming language, of course it sucks.

If you treat shell as a DSL for files and streams, nothing can beat it. Shell is amazing.

I'm sceptical a bunch of Rust macros can beat shell. I think you'd better off writing a few smaller programs that use STDIO and stringing them together with shell.


>1000+ lines of shell scripts.

Any time I have ever heard that, I've heard someone chime in "You shouldn't be using shell scripts for that."

Can you explain a use-case where long shell scripts are superior to a scripting language like Python?

p.s. I like that your language is statically typed.


Shell syntax isn't "wacky", it's extremely error prone.

Using shell script instead of a sane language is like opening beer with your teeth because you can't be bothered to get a bottle opener.


Many complain that shell scripting isn't suitable for anything longer than few lines.

I had wrote some shell software (~5k loc without comment i think?) and agree.

I was using shell because the project want to maintain compatibility between different distros (including some weird customized one without `ps` and `sed`), but that's all. Shell is not a good choice for things other than scripting.


Shell scripts don't scale and are hard to maintain. Literally any programming language would be a better choice for the same task.

I’ve written a ridiculous number of shell scripts to automate many many things. It’s great for doing something now, and it’s great as a way to interact with a machine. It is not great in all cases. Particularly: array handling is bad, it’s slow if you start using actual Bashisms, very few younger devs seem to know it.

The shell is great cuz it’s there and it can cover about 50% of use cases for server side automation, but it’s bad for the reasons mentioned above.

I love it and I hate it.


Too much shell programming?

The problem with shell scripting is that it's not meant to be a programming language at all. Its philosophy is that anything that can be a program should be, with a few capabilities and builtins sprinkled on top.

That is uninspiring... is totally fine to have long shell scripts, and in itself, is no easier nor harder than any other language.

Worth noting that shell is a programing environment (not language) so is highly dependent on the tools you are using or gluing together to accomplish something.


Not designed for shell scripting.

> you shouldn't write anything much as a shell script and should instead use a proper programming language

why?


Yes. The fact that shell scripting is both so powerful and yet such an ugly language is painful.

> For example, a package manager written in 1000 lines of posix shell script is not a good thing. Shell script is a bad language.

Shell is a bad language, but it is a language especially fitting for that purpose. File manipulation and external tool execution is much simpler and concise in it that in most other languages.


Yet another reason why shellscripts are bad huh.

Well, shell scripts are small helper programs, where you don't have to implement all sorts of business rules and complex object interactions. I am pretty sure most developers (I definitely) would be horrified at the prospect of having to to implement in shell what we are now doing in JS. Even if that were possible.

The likes this gets is the design simplicity and uniformity (across processes), not how it looks and what it actually does.


That's probably because most people only sporadically have to write shellscripts. If you had to write it every day, I bet you wouldn't have that problem.

Having said that, I personally don't feel shellscripting is all that intuitive either.


The problem with shell scripts is the same as automation a gui. It’s flakey and hard to maintain.

Grepping through output No uniform handling of spaces, tabs. No data structures. Multiple dialects.

Shell scripts mainly work with files and process management. So many scripts don’t handle spaces correctly. This is not a problem of the creator, but because of the language.

next

Legal | privacy