style: use long options for patch command

This commit is contained in:
XuehaiPan 2021-11-08 22:33:53 +08:00
parent 67c619d4f2
commit b86fdfeb09

View File

@ -167,7 +167,7 @@ module Homebrew
def run_shellcheck(files, output_type, fix: false)
files = shell_scripts if files.blank?
files = files.map(&:realpath)
files = files.map(&:realpath) # use absolute file paths
args = [
"--shell=bash",
@ -181,8 +181,13 @@ module Homebrew
]
if fix
# patch options:
# --get=0 : suppress environment variable `PATCH_GET`, ignore RCS, ClearCase, Perforce, and SCCS
# --force : we know what we are doing, force apply patches
# --directory=/ : change to root directory, since we use absolute file paths
# --strip=0 : do not strip path prefixes, since we are at root directory
patch_command = %w[patch --get=0 --force --directory=/ --strip=0]
patches = system_command(shellcheck, args: ["--format=diff", *args]).stdout
patch_command = %w[patch -g 0 -f -d / -p0]
Utils.popen_write(*patch_command) { |p| p.write(patches) }
end