-
Notifications
You must be signed in to change notification settings - Fork 1.2k
-init is now taken into account when -e is used #14190
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
base: trunk
Are you sure you want to change the base?
Conversation
This also fixes |
What happens with
You could have a first commit that just move the code around, and then a commit for the change. Note: I notice that |
Another issue I have not been able to untangle this afternoon is that |
The above also means that |
This is because the arguments after the file are expected to be the ones given to the script you're calling:
However, annoyingly it isn't very well documented either. The man page only shows the following syntax:
I think it should probably be something like
similar to the syntax from the |
I pushed a commit that makes it so initialisation file lookup is disabled on scripts (including -stdin and -e). Passing -init still works in that commit. And another commit that introduces -yesinit that allows to still lookup initialization files even when running scripts. |
My intuition is that the semantics of Regardless, the name doesn't work - the opposite of "no" is not "yes" here (the opposite of the instruction "process no init files" is not "process yes init files", if you see what I mean). Not sure what it ought to be, but perhaps something more like |
This is not the main thing this PR aims to solve. I included it for the sake of completeness, but I'm happy to remove it.
I am aware, I did not find anything better, and I thought it was understandable enough and at least a little funny. I thought the proper name would have been -init which is taken. -with-init is good. |
cc @dbuenzli : you have experience running script through the toplevel, and may have valuable feedback on the desirable semantics with respect to initialization files. |
When you run scripts you generally want to be able to invoke it regardless of your
It is mostly what
|
Right now, with init.ml
Running ocaml -init init.ml works; it launches a toplevel where print_endline a works as expected.
However running
ocaml -init init.ml -e "print_endline a;;"
giveUnbound value a
.And
ocaml -init doesnotexist.ml -e "print_endline a;;"
also givesUnbound value a
and no other error.This PR fixes that behaviour by reading the init argument before running a script.
It is a one line change, but code order is changed in order for the extra function to be available.