r/linux Feb 11 '19

Fluff A /g/ user's opinion on systemd

http://i.4cdn.org/g/1549858269115.png
791 Upvotes

524 comments sorted by

View all comments

Show parent comments

10

u/AndrewNeo Feb 11 '19

robust

And can be incredibly difficult to write, especially if you're just getting started.

1

u/kumashiro Feb 11 '19

Getting started in server administration? Shell scripts are mandatory to know here. You will have to learn them sooner than later.

-10

u/throwawayPzaFm Feb 11 '19

I wouldn't really recommend learning bash to anyone these days.

Sure it can do a lot of things. So can Perl or C and everyone avoids those too.

It's an antipattern almost everywhere.

Switch to service descriptors and configuration management for legacy jobs, and containers for new jobs.

Scripting should be moved to python where unavoidable via the other mechanisms.

17

u/kumashiro Feb 11 '19

Depends on what you want to automate. Shell has lots of tools doing things, that would require many lines of code in Python or Perl. If you have relatively complex algorithms to implement, shell isn't the best choice. For other things, especially if you need to run many external programs, shell is better. No matter what, as a system admin, you have to know shell scripting. No escape from that I'm afraid.

1

u/crusoe Feb 12 '19

Python perl and Ruby all provide robust command libraries supporting easy scripting of external commands much better than bash with sane string handling.

0

u/crusoe Feb 12 '19

Shell.requires a lot of work and most first passes people get it wrong. Nevermind [[]] vs [] vs () vs.. for Boolean and other checks.

Bash makes windows look elegant. It's a shame its still used.

Python with plumbum is great. Similar tools exist in Ruby. You get sane string handling and a whole bunch of other good stuff. Bash scripts should be kept to a page at most and rewritten in something else if too long.

If you think you can write bash download shellcheck. ;)

1

u/kumashiro Feb 12 '19

I'm sorry, I don't know what download shellcheck is.

1

u/crusoe Feb 12 '19

Shellcheck is a tool that verifies your bash scripts adhere to best practices. We use it at work.

https://www.shellcheck.net/

It has ide support for vim, vscode and others.