-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks; nice work!
def split_args(args) | ||
double_dash_index = args.find_index("--") | ||
if double_dash_index | ||
[args[0...double_dash_index], args[double_dash_index..-1]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the start/end indices can be omitted:
[args[0...double_dash_index], args[double_dash_index..-1]] | |
[args[...double_dash_index], args[double_dash_index..]] |
or, at the very least:
[args[0...double_dash_index], args[double_dash_index..-1]] | |
[args[0...double_dash_index], args[double_dash_index..]] |
case mode | ||
when :ccld | ||
cflags + args + cppflags + ldflags | ||
cflags + args + cppflags + ldflags + @positional_args | ||
when :cxxld | ||
cxxflags + args + cppflags + ldflags | ||
cxxflags + args + cppflags + ldflags + @positional_args | ||
when :cc | ||
cflags + args + cppflags | ||
cflags + args + cppflags + @positional_args | ||
when :cxx | ||
cxxflags + args + cppflags | ||
cxxflags + args + cppflags + @positional_args | ||
when :ccE | ||
args + cppflags | ||
args + cppflags + @positional_args | ||
when :cpp | ||
args + cppflags | ||
args + cppflags + @positional_args | ||
when :ld | ||
ldflags + args | ||
ldflags + args + @positional_args | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to deduplicate all these ... + @positional_args
.
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?The
cc
shim currently does not handle invocations where--
is passed as an argument, which (conventionally) indicates that all following arguments be treated as positional (non-optional) arguments. As a result, any refurbished args may get appended after the--
where they are erroneously treated as input file paths:This kind of error was encountered in the wild in some core PRs, e.g. Homebrew/homebrew-core#203929, Homebrew/homebrew-core#203934, Homebrew/homebrew-core#203932, Homebrew/homebrew-core#203944.
This pull request ensures that any modifications to the arguments are applied before the
--
(if--
is present).Before:
After: