Skip to content

fix: need to capture all scripting args when script arg is detected #12422

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

Closed
wants to merge 7 commits into from
Closed

fix: need to capture all scripting args when script arg is detected #12422

wants to merge 7 commits into from

Conversation

philwalk
Copy link
Contributor

@philwalk philwalk commented May 11, 2021

This fixes 2 issues:

  1. rename mispelled array scripting_args to script_args
  2. capture potentially lost scripting args

An example of the 2nd issue would be if a script expects arguments -script, '-repl, '-run, etc.
Here's a script that prints all arguments, and what it should print.

scala showargs.sc a b c -repl -run -script -debug
arg  0:[a]
arg  1:[b]
arg  2:[c]
arg  3:[-repl]
arg  4:[-run]
arg  5:[-script]
arg  6:[-debug]

Here's the same script called via scalac -script:

$ scalac -script ssrc/showargs.sc a b c -run -repl -script
arg  0:[a]
arg  1:[b]
arg  2:[c]
arg  3:[-repl]
arg  4:[-run]
arg  5:[-script]
arg  6:[-debug]

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @philwalk. Can we add regression tests for the spotted problems?

@philwalk
Copy link
Contributor Author

Thanks @philwalk. Can we add regression tests for the spotted problems?
I can add some tests.

@philwalk
Copy link
Contributor Author

Two tests are now added to verify that script arguments are preserved, even when they collide with dist/bin bash script options.

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @philwalk 🎉

Could you please rebase against master (instead of merge master into the PR)?

@philwalk
Copy link
Contributor Author

philwalk commented May 13, 2021

LGTM, thanks @philwalk 🎉

Could you please rebase against master (instead of merge master into the PR)?

Ok. I'm not a git expert, but perhaps my default git settings are causing problems. The only thing I did differently on this PR was to fetch upstream periodically so I could avoid merge issues.

I assume the requirement is that in the future, I do a git rebase master after commits, and before pushing changes.

Is there anything I still need to do here for this PR? If so, I might need to create a new PR for these changes.
I just changed the pulldown to Enable auto-merge (rebase) on this page, hopefully that's correct.

I notice the [Merge Pull Request] button below. I'm guessing that should be changed to [Rebase and Merge]

@liufengyun
Copy link
Contributor

The only thing I did differently on this PR was to fetch upstream periodically so I could avoid merge issues.
I assume the requirement is that in the future, I do a git rebase master after commits, and before pushing changes.

Yes, using rebase will avoid the merge commits thus makes history cleaner. And then you can (have to) force push to the PR.

I just changed the pulldown to Enable auto-merge (rebase) on this page, hopefully that's correct.
I notice the [Merge Pull Request] button below. I'm guessing that should be changed to [Rebase and Merge]

Thanks, I don't know that rebase and merge exists, I'll use that.

@liufengyun
Copy link
Contributor

I notice the [Merge Pull Request] button below. I'm guessing that should be changed to [Rebase and Merge]

Thanks, I don't know that rebase and merge exists, I'll use that.

I notice rebase and merge will not create a merge commit. It's still preferable to have a merge commit. Could you instead rebase and force push to the PR branch? Hopefully that will get rid of the merge commits and we can merge it as usual.

@philwalk
Copy link
Contributor Author

I notice rebase and merge will not create a merge commit. It's still preferable to have a merge commit. Could you instead rebase and force push to the PR branch? Hopefully that will get rid of the merge commits and we can merge it as usual.

I tried to rebase but there are merge requirements that I'm not qualified to resolve, so I think I should close this PR and create another with the changes from this PR.

@philwalk philwalk closed this May 13, 2021
@philwalk
Copy link
Contributor Author

I will create a new pull request with identical changes in the same 4 files:

compiler/test-resources/scripting/showArgs.sc
compiler/test/dotty/tools/scripting/BashScriptsTests.scala
dist/bin/scala
dist/bin/scalac

@philwalk
Copy link
Contributor Author

this is superceded by #12467

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants