2015-01-21 3 views
0

당신이 명령을 실행할 exec을 사용할 수 있습니다, 카피 스트라 노의 말, 당신이 무엇을 어떻게 적 : 그것은 작동긴 exec 명령을 어떻게 분할합니까? 당신이 오랫동안 간부 라인이있을 때 당신이 배포 스크립트를 작성하는 루비의

exec 'bundle exec promiscuous publish "Xaaron::User.all" && bundle exec promiscuous publish "Xaaron::Role.all" && bundle exec promiscuous publish "Xaaron::Permission.all" && bundle exec promiscuous publish "Xaaron::ApiKey.all"' 

을, 그것을 실행 , 그것은 내가 원하는 것을 수행하지만 더 많이 추가해야합니다. 그리고 조금 깁니다. 어떻게 여러 줄로 나누고 정상적으로 실행합니까?

당신은 별도의 행으로 문자열을 분할 할 수 있습니다

답변

2

:

exec "bundle install && " + 
    "apt-get install nginx && " + 
    "cat file" 
4

무엇

exec [ 
    'bundle exec promiscuous publish "Xaaron::User.all"', 
    'bundle exec promiscuous publish "Xaaron::Role.all"', 
    'bundle exec promiscuous publish "Xaaron::Permission.all"', 
    'bundle exec promiscuous publish "Xaaron::ApiKey.all"', 
].join(" && ") 

또는이 특정 경우에

에 대한,

exec %w[User Role Permission ApiKey] 
.map{|e| "bundle exec promiscuous publish \"Xaaron::#{e}.all\""}.join(" && ")