Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shims/super/cc: handle double dash in args #19082

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Library/Homebrew/shims/super/cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class Cmd

def initialize(arg0, args)
@arg0 = arg0
@args = args.freeze
split_args = split_args_at_double_dash(args)
@args = split_args[0].freeze
@positional_args = split_args[1].freeze
@config = ENV.fetch("HOMEBREW_CCCFG", "")
@prefix = ENV["HOMEBREW_PREFIX"]
@cellar = ENV["HOMEBREW_CELLAR"]
Expand All @@ -57,6 +59,15 @@ class Cmd
@keg_regex = %r{(#{Regexp.escape(opt)}|#{Regexp.escape(cellar)})/([\w+-.@]+)}
end

def split_args_at_double_dash(args)
double_dash_index = args.find_index("--")
if double_dash_index
[args[...double_dash_index], args[double_dash_index..]]
else
[args, []]
end
end

def mode
if @arg0 == "cpp"
:cpp
Expand Down Expand Up @@ -130,7 +141,7 @@ class Cmd
end
end

case mode
optional_args = case mode
when :ccld
cflags + args + cppflags + ldflags
when :cxxld
Expand All @@ -146,6 +157,8 @@ class Cmd
when :ld
ldflags + args
end

optional_args + @positional_args
end

def refurbished_args
Expand Down
Loading