Skip to content

Commit

Permalink
shims/super/cc: handle double dash in args
Browse files Browse the repository at this point in the history
  • Loading branch information
alebcay committed Jan 12, 2025
1 parent 2432d01 commit 1ec8a04
Showing 1 changed file with 15 additions and 2 deletions.
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

0 comments on commit 1ec8a04

Please sign in to comment.