-
Notifications
You must be signed in to change notification settings - Fork 138
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
Read the input from stdin instead of a .frm file #265
Conversation
Now setup parameters are supported. Example: cat <<END | form -stdin
#:workspace 1234K
#:wtimestats on
On setup;
S x;
L F = (1+x)^2;
P;
.end
END |
Squashed into one commit. Ready to merge (once the others agree). Possible improvement: currently the stdin is read one by one, for simplicity, by |
Normally for stdin as file input - is used, if - must be given as parameter to program it's -- -. Can -stdin be replaced by - for consistency among other command line software? so it should just be |
I think |
By the way, the |
Now the filename |
Is this change still ready to be merged? |
It seems that there are no conflicts with the current master branch (though the current master fails to pass the tests and travis-ci.org is dead), but probably it has conflicts with 5.0 via |
I've changed the pull request so that the banner is printed first and the line echoing is disabled. Now form can be used pretty cleanly from the command line as if it were an interpreter! I imagine this may be useful when teaching form. @tueda can you check if moving the header print is safe for parFORM? If so ,we can merge it :) |
We can ignore ParFORM for now because MPI doesn't automatically broadcast stdin (see, for example, https://stackoverflow.com/q/49016638) so it doesn't work anyway. I have added an error message for the case where You can use "Rebase and merge" (or "Squash and merge" if you want). |
I've moved the printing of the header, even when we don't use stdin mode. I think it's safe ( |
This patch makes FORM read the input from the standard input rather than a file when "-" is given in the command line option. Example: cat <<END | form - #:workspace 1234K #:wtimestats on On setup; S x; L F = (1+x)^2; P; .end END Stdin mode is forbidden in ParFORM, since in many MPI implementations stdin is only accessible from one of the MPI processes.
- Disable line echoing by default in stdin mode
36f5536 causes tform's header to always state "-1 workers", by the way. |
Right, I've confirmed that If |
Actually, this also breaks the |
Maybe a solution would be:
though I'm not sure what is the exact differences between |
A safer option:
By the way, if FORM always doesn't print the version header for the stdin case, how can one know the exact version of FORM running? Currently, parsing the version header is the only way to know that. |
|
@tueda I'll push your latest suggestion. I've tested it and it seems to work. Running form without any arguments or with |
Yes, indeed this seems to be enough. The user program may run FORM twice,
Nice! Go ahead. |
Work in progress. This is an experimental implementation of #264. Example:
Setup parameters (
#:...
) are not supported yet.It also works with Windows (an binary available in AppVeyor: https://ci.appveyor.com/project/tueda/form/build/job/5ndaxgejblwqa4ho/artifacts).