Hacker News new | past | comments | ask | show | jobs | submit login
Run System Commands in Ruby – When to use which methods to run shell commands (kirillshevch.medium.com)
25 points by thunderbong 65 days ago | hide | past | favorite | 8 comments



I can't help but notice that all of those methods take a single command line string as a parameter. That's arguably fine on Windows, but not on Linux. So: how is that string broken down into the array of strings for the ultimate execve() call, in Ruby? Does Ruby parse it on its own (using some dialect of shell for quoting), or does it invoke the shell to do the heavy lifting, or?..


There is also a variant of 'system' which takes multiple agruments. It invokes the program in the first argument and passes the other arguments directly without going through shell so no globs etc. can take place. But this is not mentioned in the article but it is in Ruby docs


While the article says that backticks don't provide access to the exit status, you can retrieve it with $?.exitstatus.


Lately I've been using Bun shell for writing scripts, it's a nice alternative for those who prefer JavaScript syntax over Ruby: https://bun.sh/docs/runtime/shell


The text blends in so well with the background, it is barely readable for me.


Check your browser extensions and add-ons.

The title and body text have a 15.52:1 contrast ratio with the background, which is acceptable by all accessibility standards.

The subtitle and background have a 5.32:1 contrast ratio with the background. This would be considered acceptable by most accessibility standards, though I would like it around 9:1.


Black text on white background for me. Do you have an add-on or something changing the site?


Yeah you're right, it's my FF acting weird.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

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

Search: