-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Assign PROGRAM_FILE earlier #22092
Assign PROGRAM_FILE earlier #22092
Conversation
I discovered a use case where it would be nice to be able to access `PROGRAM_FILE` while within the .juliarc.jl. The global variable is now assigned and available within `--load` file or the .juliarc.jl. Additionally, PROGRAM_FILE is now a constant.
Note we may not want to back port this is a breaking change if users are accessing |
I don't think it's good to change the behavior of juliarc this far after feature freeze, after 2 rc's. Could you describe the use case more? Making juliarc behavior depend on PROGRAM_FILE seems like a strange thing to do |
I needed to run |
Completely reasonable. I'll drop the backport label. |
Would this solve #21823 then? |
It may also be a good idea to set an ENV variable when running within the |
The separate PR I was referring to: #22094 |
[ci skip]
Added a NEWS entry since this a breaking change without a warning. Overall I think this change is still worthwhile as it makes |
Expanded |
test/cmdlineargs.jl
Outdated
println(PROGRAM_FILE) | ||
include(\"$(escape(b))\") | ||
""" | ||
) |
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.
nitpick, but I don't think it's usually worth using up vertical space to put close parens on their own line
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'll update this to match the Base style
test/cmdlineargs.jl
Outdated
write(a, """ | ||
println(@__FILE__) | ||
println(PROGRAM_FILE) | ||
include(\"$(escape(b))\") |
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'll update this to use escape_string
Ready to squash and merge |
write(a, """ | ||
println(@__FILE__) | ||
println(PROGRAM_FILE) | ||
println(length(ARGS)) |
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.
we don't care about testing ARGS length any more?
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.
No. Originally I added this since the number of arguments could vary depending on when we would run the check. I could still include this check but it would only be for verifying that the ARGS
were no longer includes the PROGRAM_FILE
as ARGS[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.
why not keep checking the new expected value?
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.
The tests prior to this ("test passing arguments") deals with testing the number of ARGS already. Having them in this section is redundant and just adds noise as the length(ARGS) == 0
. I'll make sure that the previous section covers what these tests previously did.
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.
Added new tests to address this
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.
lgtm
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 Tony
Will merge later today |
I'll hold off on merging today since I modified the tests. Essentially, the latest changes include:
|
* Assign PROGRAM_FILE earlier I discovered a use case where it would be nice to be able to access `PROGRAM_FILE` while within the .juliarc.jl. The global variable is now assigned and available within `--load` file or the .juliarc.jl. Additionally, PROGRAM_FILE is now a constant. * Add to NEWS [ci skip] * Test startup-file and PROGRAM_FILE * Modify user home properly on Windows * Style correction and remove escape function * Expand arguments tests to include the startup-file * Refactor PROGRAM_FILE tests
I discovered a use case where it would be nice to be able to access
PROGRAM_FILE
while within the .juliarc.jl. The global variable is now assigned and available within--load
file or the .juliarc.jl.Additionally,
PROGRAM_FILE
is now a constant.Follow up to #14114