Sadly, 9 out of 10 environments lack a Ruby interpreter out of the box. Are you going to add 5 minutes to your docker build to compile Ruby? Probably not. Luckily, I've found that Perl has most of the best features of Ruby, and it's installed everywhere. It's time to Make Perl Great Again.
Ruby: A great language for shell scripts
101–110 of 368 posts
Re: Ruby: A great language for shell scripts
#102I sometimes wonder why we don't see ruby used for shell stuff more often. It inherited most of the good stuff for shell scripting from Perl, and Perl took a lot of it's syntax from sh and sed and awk, so almost anything you can do in shell script you can do in ruby, but with an option of making it gradually less terse and more readable, while having sane variables and data handling from the start. Also ruby is great…
Instability. Ruby has not been the same language for very long. Migrating to 1.9 was a huge hassle for many firms. This may seem like a long time ago in tech years; but then there was Ruby 2.0; and shell scripts, meanwhile, have stayed the same the whole time. A secondary reason is that Ruby has been very slow for much of its life, which means that for situations where you need to run a huge stack of scripts -- init…
I learned enough PowerShell to be comfortable using it, and then picked up Bash and Ruby a few years later.
I longed for a Ruby shell for a couple years.
Re: Ruby: A great language for shell scripts
#103Earlier quoted context omitted.
Ubuntu, Debian, Arch, CentOS - none of these, as far as I know, ship with a Ruby interpreter by default. I’d like to be wrong, but I don’t think many do.
It's been a while since I reinstalled Ubuntu, but the latest version (24.04 LTS) definitely includes Ruby (3.2) according to their docs [0]. [0] https://canonical.com/blog/canonical-releases-ubuntu-24-04-n... .
Re: Ruby: A great language for shell scripts
#104I sometimes wonder why we don't see ruby used for shell stuff more often. It inherited most of the good stuff for shell scripting from Perl, and Perl took a lot of it's syntax from sh and sed and awk, so almost anything you can do in shell script you can do in ruby, but with an option of making it gradually less terse and more readable, while having sane variables and data handling from the start. Also ruby is great…
What tooling do you use that’s written in Go? I’d have said that Python is the most popular language for tooling, by a country mile. The only tooling I know that’s written in Go is Docker.
Re: Ruby: A great language for shell scripts
#105Re: Ruby: A great language for shell scripts
#106No it’s not a great language. Too many ways to do the same thing. Not packaged by default on most Linux. Monkey patching makes things even harder to debug.
Re: Ruby: A great language for shell scripts
#107Earlier quoted context omitted.
> It was a lot easier than our Python 2 to 3 conversations were. Python's is (present tense very much intended) notoriously one of the worst-managed transitions in programming language history, so that's not exactly a ringing endorsement.
It is completely relevant, because it’s arguing against the claim that Ruby was unstable once back in 2005.
Re: Ruby: A great language for shell scripts
#108I sometimes wonder why we don't see ruby used for shell stuff more often. It inherited most of the good stuff for shell scripting from Perl, and Perl took a lot of it's syntax from sh and sed and awk, so almost anything you can do in shell script you can do in ruby, but with an option of making it gradually less terse and more readable, while having sane variables and data handling from the start. Also ruby is great…
The reason we don't see Ruby used more for shell stuff is because Python won this particular war. It's already installed on basically every Linux distribution out there, and this simple fact outweighs all other language considerations for probably >95% of people who are writing shell scripts in something that isn't Bash.
Personally, I don't much like Python, and even though Ruby is not my favorite language either, I find it much better than Python for this kind of work. But I don't get to decide how Debian builds their infrastructure, so in the end, I tend to use Python.
Re: Ruby: A great language for shell scripts
#109I sometimes wonder why we don't see ruby used for shell stuff more often. It inherited most of the good stuff for shell scripting from Perl, and Perl took a lot of it's syntax from sh and sed and awk, so almost anything you can do in shell script you can do in ruby, but with an option of making it gradually less terse and more readable, while having sane variables and data handling from the start. Also ruby is great…
> ... maybe extract those files to required files, add gems, whatever. CPAN is the killer feature of Perl. It just works. First off, most of the time I don't need a CPAN module for doing shell scripting in perl. Perl itself is rich enough with the file manipulations that are needed for any script of less than 100 lines. My experiences with Ruby and installing gems have been less pleasant. Different implementations of…
Re: Ruby: A great language for shell scripts
#110Totally agree! Other tricks I rely on: a) put a `binding.irb` (or `binding.pry`) in any rescue block you may have in your script - it'll allow you to jump in and see what went wrong in an interactive way. (You'll need a `require 'irb'` in your script too, ofc) b) I always use `Pathname` instead of `File` - it's part of the standard library, is a drop in replacement for `File` (and `Dir`) and generally has a much more…
> You'll need a `require 'irb'` in your script too, ofc irb is a part of Ruby core, so this isn’t true. (It may have been at one point? I’m not sure.) I love binding.irb. I use it all the time.