How is a newlisp script invoked?
newlisp <demo.lsp
works as expected; but creating demo.lsp as an executable file starting with "#!/usr/bin/env newlisp" is not intrepeting the content???
./demo.lsp
newlisp demo.lsp
it goes interactive. does the interpreter require newlisp scripts to be fed as stdin?
-George
Yes, like this:
./demo.lsp
newlisp demo.lsp
... and make sure scripts end with '(exit)'. If not you end up in the interactive command line, and '#!/usr/bin/env newlisp' will works as expected if the file has executable permissions.
Here are examples for Unix filters and pipes:
http://www.newlisp.org/downloads/CodePatterns.html#toc-2
okay, excellent, that's resolved. I wasn't expecting the exit function as a requirement.
do you know anyway to coerce options into interpreter without using the full path? Is there a possibility of setting them within the script, like the shell set function? I'd like to use
#!/usr/bin/env newlisp -s 100000 -m 10
but that fails, env is somehow interpreting the options as part of the filename. "#!/usr/bin/env newlisp" works fine.
#!/usr/local/newlisp-10.2.8./bin/newlisp-10.2.8 -s 100000 -m 10
works but I don't want to hard code the path in the script.
-George
It very much depends on the UNIX flavor how these things are handled. E.g. the following script:
#!/usr/bin/env newlisp -s 123456
(println (main-args))
(println (sys-info))
(exit)
works fine on Mac OS X (a BSD-like UNIX flavor):
$ ./script
("newlisp" "-s" "123456" "./script")
(457 268435456 389 2 0 123456 0 613 10217 131)
$
but fails on FreeBSD:
$ ./script
env: newlisp -s 123456: No such file or directory
$
... and would work on FreeBSD with the absolute path: #!/usr/local/bin/newlisp -s 123456
... and SunOS will completely ignore options in the header line:
$ ./script
("newlisp" "./script")
(312 268435456 300 2 0 1024 8500 4) <-- running an older version with different sys-info format
$
the install should supply a link newlisp -> newlisp-10.2.8, so you don't need the version number when using an absolute path in the header line.