在自制软件公式中运行shell脚本

时间:2017-07-23 08:45:08

标签: shell homebrew homebrew-cask

我想在homebrew(cask)公式中运行本地shell脚本,该公式在安装后进行一些修改。木桶公式是稳定的,因为它总是安装'最新',因此手动插入不应该在不久的将来被更新覆盖(我希望)。

我试过

exec '~/bin/script.sh'
system '~/bin/script.sh'

哪两个都不起作用。我该怎么做?

编辑:尝试使用@Ortomalas答案我得到:

Error: Command failed to execute!

==> Failed command:
/usr/bin/sudo -E -- sed -i .bak 20i<style>*{text-rendering: optimizeLegibility;}</style>  /Applications/RStudio.app/Contents/Resources/www/index.htm

==> Standard Output of failed command:


==> Standard Error of failed command:
sed: 1: "20i<style>*{text-render ...": command i expects \ followed by text

postflight

postflight do
    # Unhide the application
      system_command 'sed',
                     args: ['-i .bak', "20i\<style>*{text-rendering: optimizeLegibility;}</style>\ ", "#{appdir}/RStudio.app/Contents/Resources/www/index.htm"],
                     sudo: true
end

我尝试了使用system_command的各种方法,但我并没有成功。上面的这个例子提出了一次尝试。

作为一种解决方法,我按如下方式执行:

brew cask install rstudio-daily && bash ~/bin/Fira-code-ligatures.sh

但是,我真的更愿意将我的自定义bash脚本注入homebrew公式。

1 个答案:

答案 0 :(得分:1)

您可以添加postflight块。 parralels-desktop cask就是这样的:

postflight do
    # Unhide the application
    system_command '/usr/bin/chflags',
                   args: ['nohidden', "#{appdir}/Parallels Desktop.app"],
                   sudo: true
  end

用您自己的值替换值。

相关问题