docs: mention shebang rewrite in the formula cookbook

This commit is contained in:
Thierry Moisan 2021-04-24 14:12:51 -04:00
parent fb7d19c661
commit 5b31a0623b
No known key found for this signature in database
GPG Key ID: 2F797AD837292E8C

View File

@ -750,6 +750,10 @@ ln_s libexec/"name", bin
The symlinks created by [`install_symlink`](https://rubydoc.brew.sh/Pathname#install_symlink-instance_method) are guaranteed to be relative. `ln_s` will only produce a relative symlink when given a relative path.
### Rewriting a script shebang
In some cases, the formula goal is to install a script written in an interpreted language, such as Python or Perl, and use it as an executable. Homebrew provides utilities to rewrite the shebang of a script so its path matches the interpreter dependency. For example, the [`icdiff` formula](https://github.com/Homebrew/homebrew-core/blob/7beae5ab57c65249403699b2b0700fbccf14e6cb/Formula/icdiff.rb) uses such utility.
### Handling files that should persist over formula upgrades
For example, Ruby 1.9s gems should be installed to `var/lib/ruby/` so that gems dont need to be reinstalled when upgrading Ruby. You can usually do this with symlink trickery, or (ideally) a configure option.