1

I would like to run a local shell script within a homebrew (cask) formula which does some modifications after the installation. The cask formula is stable since it always installs 'latest' and therefore the manual insertion should not be overwritten by updates in the near future (I hope).

I tried

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

which both does not work. How do I have to do this?

EDIT: Trying to use @Ortomalas answer I get:

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

I tried various approaches using system_command but I was not sucessfully with any. This example above presents one attempt.

As a workaround, I do it as follows:

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

However, I really would prefer to intregate my custom bash script into the homebrew formula.

pat-s
  • 5,992
  • 1
  • 32
  • 60

1 Answers1

1

You can include a postflight block. The parralels-desktop cask does it like this:

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

Replace the values with your own.

Ortomala Lokni
  • 56,620
  • 24
  • 188
  • 240