From b86fdfeb09e55678f5d35a738f55d7bc04dbfd54 Mon Sep 17 00:00:00 2001 From: XuehaiPan Date: Mon, 8 Nov 2021 22:33:53 +0800 Subject: [PATCH] style: use long options for `patch` command --- Library/Homebrew/style.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/style.rb b/Library/Homebrew/style.rb index 3375ba3116..486e44cdd4 100644 --- a/Library/Homebrew/style.rb +++ b/Library/Homebrew/style.rb @@ -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