I'm new to GAP and have some trouble with its script. Here is the script that I wrote: foo.gap
#!/usr/bin/gap -q
Display(1 + 1);
quit;
I expected if I type "./foo.gap" then it displays 2 and returns control:
$ ./foo.gap
2
$
However it doesn't return control as I expected; it still waiting commands (that is, typing "Display(2 + 3);" returns 5, for example).
$ ./foo.gap
2
Display(2 + 3);
5
It seems that, however, typing these separately works.
$ gap -q
Display(1 + 1);
2
quit;
$
Would you please help me? What's wrong with the first script, foo.gap? Thank you.
One needs to redirect the input to GAP - this is why
cat foo.gap | gap -qworks. One of recipes could be to use the following:Here
-bsuppresses the banner and-qenables the "quiet" mode, so the script will print only GAP's output.Note, however, that unless you have specific goals in mind which require calling GAP from such a script, you may also put the GAP code into the text file, say,
myfile.g, and then read it into GAP like in the examples hereor start GAP and call
Read(...)from the GAP command line.P.S. Please note that there are well-established support channels for GAP users such as GAP Forum and GAP Support where a question on GAP might be noticed quicker by a larger number of GAP users and developers of GAP and its packages; therefore (dependently on the question) GAP Forum and GAP Support may happen to be more suitable place for asking.