【发布时间】:2017-07-23 08:45:07
【问题描述】:
我想在 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 公式中。
【问题讨论】:
-
您是否在
~/bin/Fira-code-ligatures.sh上设置了chmod +x?。你能告诉我们你的飞行后块吗? -
查看新更新@OrtomalaLokni
-
可以给我们看一下
~/bin/Fira-code-ligatures.sh的内容吗? -
sed -i.bak '20i\ <style>*{text-rendering: optimizeLegibility;}</style>\ ' /Applications/RStudio.app/Contents/Resources/www/index.htm-> 使用上面的“解决方法”可以正常工作
标签: shell homebrew homebrew-cask