I 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…
I think the quality of a language for shell scripting is often secondary. What’s of greater significance is where it is at. I.e., does it have it already installed? The answer with Linux and Bash is almost always “yes”. Not so with ruby. The moment you start asking the user to install things, you’ve opened up the possibility for writing a program rather than a shell script. The lifecycle of a piece of software is alm…
Ruby: A great language for shell scripts
141–150 of 368 posts
Re: Ruby: A great language for shell scripts
#142I 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…
I think golang is used because you can easily create a single static binary, which is incredibly easy to distribute. I often find non-trivial CLI tools written in Python cumbersome because of the dependency wrangling necessary.
Re: Ruby: A great language for shell scripts
#143If you never coded in ruby before, but use macOS, you already have ruby installed. Just open terminal and type irb to bring up the ruby interpreter and try out the code in the article.
Re: Ruby: A great language for shell scripts
#144Earlier quoted context omitted.
> I sometimes wonder why we don't see ruby used for shell stuff more often. 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 m…
> It's already installed on basically every Linux distribution out there, PEP 668 pretty much negates this though. To do anything you need a python environment set up per script/project w/e
Re: Ruby: A great language for shell scripts
#145Being able to call external commands with backticks alone makes it better suited than Python for shell scripting.
Involving an entirely separate parser just to split your args up feels like a footgun to me.
Python's `sh` handles this rather nicely:
Re: Ruby: A great language for shell scripts
#146I’ve been enjoying nushell
Being able to just paste json into a terminal and immediately start working with it in a structured way feels like a superpower.
The interactive help and well-thought-out error messages feel like a hug.
Re: Ruby: A great language for shell scripts
#147Earlier quoted context omitted.
I think the quality of a language for shell scripting is often secondary. What’s of greater significance is where it is at. I.e., does it have it already installed? The answer with Linux and Bash is almost always “yes”. Not so with ruby. The moment you start asking the user to install things, you’ve opened up the possibility for writing a program rather than a shell script. The lifecycle of a piece of software is alm…
This is indeed why I use Perl over Ruby. As long as it's not for a Window machine, a Perl script is deployed by copying it over and that's it.
Re: Ruby: A great language for shell scripts
#148Earlier quoted context omitted.
The “editor tooling” in Jetbrains’ Rubymine is fabulous.
That's true, I've heard good things! I don't use Jetbrains products, but I'm glad they work well here.
Re: Ruby: A great language for shell scripts
#149Earlier quoted context omitted.
I think golang is used because you can easily create a single static binary, which is incredibly easy to distribute. I often find non-trivial CLI tools written in Python cumbersome because of the dependency wrangling necessary.
I think one of the advantages of a script is that you can quickly check what it is doing by simply opening it - an executable won't afford that.
Re: Ruby: A great language for shell scripts
#150Being able to call external commands with backticks alone makes it better suited than Python for shell scripting.
If you've reached for something with more structure than the string-soup that is bash, why would you then embrace the string-soup that is invoking subprocesses with backticks? Involving an entirely separate parser just to split your args up feels like a footgun to me. Python's `sh` handles this rather nicely: http://sh.readthedocs.io/en/latest/