Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think it's time people start using something better than bash/zsh that is decades old, like fish or even come up with a more modern shell.

Even by looking at these examples, you see it has less verbosity like "then" and "do", you can reference arguments as $argv instead of cryptic $@ and exit status code as $status instead of $? which is confusing with $! and the likes.

https://blog.codeship.com/lets-talk-about-shell-scripting/

https://fishshell.com/docs/current/tutorial.html

Shell is such an integral part of admins and programmers workflow yet I find it hard to believe this field has been so slow at improving. Even the fish site jokingly states "Finally, a command line shell for the 90s" implying the others are even older.



You might find the Oil Blog[0] interesting, there are a lot of interesting thoughts there about what a truly modern shell might look like.

[0]: https://www.oilshell.org/blog/


Great read, thanks.


I think a big issue is that bash is available everywhere, while fish might not be. There's also the fact that a lot of us have fancy dotfiles for our work/home computers, and switching to another shell would mean having to rewrite them in the target shell language.


So, you'd rather use something that is decades old because you can't/don't want to (ask to) install 1 new program on the server and take a weekend to rebuild your config file?

You can simply import aliases as is and in some cases, you may be able to even simplify parts of your config.

Personally, it was easy for me as I'm administering the servers and it was all just installing fish on every servers. (some dozens.)


> So, you'd rather use something that is decades old because you can't/don't want to (ask to) install 1 new program on the server and take a weekend to rebuild your config file?

Absolutely, yes. Because long story short, bash is TriedAndTrue® technology. Stuff that works.

It takes a bit of dedication to be mastered at a decent level but it pays off immensely. It's so ubiquitous it is one of those tools that you can learn once, use for the rest of your life, and use in a lot of contexts.

It's so widespread that it can bring you very far with very little.

All this being said, as someone who used to write code for a living (and now works as a System Engineer, using the bash shell everyday) I must say that if you do not do input verification (according to the language of your choice) and something goes wrong then it's your fault.


"works"

More like "better the devil you know" (if you can even say that much).

Bash doesn't scale. Every shop larger than 1 has been burned by bash gotchas. Use a real scripting language and shell out to the commands and builtins when necessary.

At my shop bash is strictly disallowed in production environments and we're all better off for it.


> Bash doesn't scale.

Thanks mate, I had a good laugh.

I wouldn't expect bash to scale anyway. That's not what it's meant for. It's meant for system administration task automation.

On a more serious note ...

In many occasions, the performance you get depends on how you tackle the problem you have, though. Even using bash and the tools from the unix toolbox, sometimes you can gain significant improvements on how you manage your data.

Anecdotal: I cannot remember the details, but I remember that rearranging the order of sorting and searching and removing duplicates (sort, sort -u, grep, uniq mainly) I saw a significant speedup.

Anecdotal (2): I cut the execution time of a night-running job from hours to minutes (tens of minutes, to be honest - but still less than an hour) just by slicing the size of a problem into smaller parts and by handling each slice in parallel (the machine had 48 cpus, but the problem was being solved "sequentially" on one cpu alone). I wrote some 30-50 lines of python, just to implement parallelism control: the rest of the problem was still handled with bash script. Partial results were reassembled at the end. Bash has coprocesses, so I might have handled that in bash as well, but python was more handy at the time (meh, i just wanted to optimize that problem).

What I am trying to say is that sometimes the "scaling" you get is justified by the size of the problem, sometimes it's not.


It's worth noting that bash is really a glue language to call other programs. If you mainly use the tools from the unix toolbox (i'm thinking of grep, for example) you really get the "scaling" (the performance) of native executable code.

Again, it really depends on how you handle your data.

Having a number of filters chained via pipes is really efficient, for example, when compared with looping over an array and executing some python/perl/ruby one-liners every time.


I should have clarified. I'm not talking about micro-optimizations. Bash doesn't scale operationally. You might be a bash wizard who never fucks up, but you're never going to be able to keep non-wizards from having to use your awful bash codebase.

Bash is not at all meant for "system administration task automation", the very idea is ludicrous. It has to be the most singularly ill-purposed invention ever to be applied towards task automation.


> Use a real scripting language and shell out to the commands and builtins when necessary.

Not to mention, for example: https://julialang.org/blog/2012/03/shelling-out-sucks


It is not webscale!


Do you guys have a different, approved shell for prod?


Nobody should be using any shell in prod


It's not just me, but convincing my team to switch to a new scripting language. Especially if they've never heard of fish and have been using bash/sh their whole careers.


Availability is a big issue. It is nearly impossible to get a seasoned sysadmin to install fish for you when bash is available.


If you're convinced your productivity may change by ditching bash, I'm not sure what kind of counterargument the sysadmin will bring.


Avoiding the next Shellshock? As bad as it was, who knows what goodies an even less-audited shell has in store


Using bash never prevented the problem in the first place.



What's wrong with something that's decades old? Bash is great for command line and small scripts. It's once you surpass 100 lines where things get problematic. At that point, you're not writing a shell script, you're writing a tiny application and need to treat it as such.


What's wrong with something that's decades old?

In the case of shells, not benefitting from the extra decades of experience. There are some horrible things that you can do with Bash just by mistyping a single character or using the wrong type of quotes or failing to appreciate how something will expand in some edge case. This is not a desirable property for an environment that people use after being paged at 4am, while their employer is losing $XXX,000/minute because something critical is down, and where the half-asleep operator is one short command away from deleting the universe without so much as a confirmation prompt.


I've started using Ammonite for scripting, which certainly feels more solid than bash.

https://github.com/lihaoyi/Ammonite

Many times previously I've starting really quickly testing/prototyping an idea in bash, which eventually grew large and unweildy. Ammonite appears like it might allow quick hacking, but also the option to easily transition your scripts into scala proper while leveraging the good bits of Java.


Why not both?

> Bash has arrays and a safe mode, which may make it just about acceptable under safe coding practices, when used correctly.

> Fish is easier to use correctly, but lacks a safe mode.

> Prototyping in fish is therefore a good idea, provided that you know how to translate correctly from fish to bash.


Doesn’t the original article say fish isn’t safe?

> Fish is easier to use correctly, but lacks a safe mode. Prototyping in fish is therefore a good idea, provided that you know how to translate correctly from fish to bash.


Just make the start. When a modern shell becomes reliable and popular enough, it'll slowly replace the old ones.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: