开发者

shell command (involving sed) works in bash but not in rake task on mac os

开发者 https://www.devze.com 2023-03-12 13:57 出处:网络
I have a rake task th开发者_运维百科at performs a shell command. When I run it from bash, the substitution worked, but when I run the rake task, the substitution did not take place.

I have a rake task th开发者_运维百科at performs a shell command. When I run it from bash, the substitution worked, but when I run the rake task, the substitution did not take place.

My rake file:

require 'rake'
namespace 'performance_tests' do
  task :test_guests_generation do

    %x{sed -e 's/NO_OF_GUESTS = \[.*]/NO_OF_GUESTS = \[400, 10]/' -i '' db/seeds.rb}
  end
end

Trying the command in Mac OS Terminal does perform the substitution:

$ sed -e 's/NO_OF_GUESTS = \[.*]/NO_OF_GUESTS = \[400, 10]/' -i '' db/seeds.rb


Um... not sure to be honest. Have you tried escaping the spaces? Can you paste the line you are working on and the desired result?

0

精彩评论

暂无评论...
验证码 换一张
取 消