Skip to content

Bypass the shell when running commands from Rake

Jacob Vosmaer requested to merge rake-bypass-shell into master

In Ruby, when you run a command like this:

system("foo bar > baz")

What actually happens is that ruby runs:

sh -c 'foo bar > baz'

While this is easy to write it can lead to all sorts of trouble with quoting. When you run your command like this:

system('foo', 'bar', out: 'baz')

You bypass the shell. This is more reliable. Also see:

https://docs.gitlab.com/ee/development/shell_commands.html#bypass-the-shell-by-splitting-commands-into-separate-tokens

Merge request reports