TiL: The difference between exec and system in Ruby

Ruby provides a few different ways to execute commands against the underlying kernel programmatically, but they all work slightly differently. The simplest way to execute a command againts the shell is to surround it in backticks. For example, the following will run the command date and return whatever was output to $stdout. current_date = `date` However, there are also more explict methods you can call. In particular, there is exec and system which look like they do the same thing at a quick glance....

September 23, 2024 · 2 min · 425 words · George Bell