-
Notifications
You must be signed in to change notification settings - Fork 123
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
#! prolog #2170
Comments
Invalid syntax. What else to expect? |
Sometimes languages will add an exception to allow shebang syntax on the first line. Mechanically, this would mean ignoring the first line of the file if it starts with This can be nice for integrating into unix-y systems. While it works out of the box with the many scripting languages that use This may or may not be a good fit for scryer-prolog, but it would certainly be useful for interacting with scryer-prolog in a shell environment. I played around with it and actually found a very hacky way to do this with scryer-prolog in bash today: $ cat test.pl
/*usr/bin/env scryer-prolog "$0" "$@" ; exit #*/
run :- write(hello),nl,halt.
:- initialization(run).
$ chmod +x test.pl
$ ./test.pl
hello The way this works is that this I don't know what to think about this. |
As far as I can tell, that's ingenious! It remains valid Prolog syntax, and can also be used as a shell file. |
Great summary, @infogulch. I would much prefer a non-hacky solution, like having scryer-prolog ignore the shebang, similar to what SWI-Prolog does. |
@infogulch, one minor improvement: Instead of |
... and avoids exploits with |
Nice polyglot hack 👍 When I run it, it works, but also shows an error at the end: ./test.pl
It can be simply fixed, by adding an additional /*usr/bin/env scryer-prolog "$0" "$@" ; exit #*/ |
The rather typical shebang kills scryer prolog.
my minimal example is a file with just :
#! prolog
The text was updated successfully, but these errors were encountered: