Hello Reinhard,
these are two different questions. First, the #! line works everywhere except on Windows. It finds the interpreter (not your script) in PATH. There is no reasonable alternative on Windows. You have to associate filename extensions with interpreters in the registry. If you are using TeX Live, you can start your script from a wrapper instead.
OK, thanks.
Try this: ------------------------------------------------------- #!/usr/bin/env texlua
dirname, filename = string.match(arg[0], '(.*[/\\])(.*)')
print('dirname='..dirname) print('filename='..filename) -------------------------------------------------------
it works as expected on Unix:
On every Unix? I once tried this with sh (echo $0) and if I remember correctly it gave me a relative path on solaris and an absolute path on linux.
You will certainly get similar results in TeX Live
I don't use TeXlive in this case, just one LuaTeX binary for luatex and texlua.
because the location of your script is determined by the wrapper, and hence by kpathsea, which returns the full path. Please note that dirname found by string.match() in the example above contains the leading directory separator already and that backslashes are supported too.
So I assume from your answer that arg[0] in my lua skript is set by kpathsea, and it contains the full path. So I can find out where I am by looking at it? Thanks again Patrick