lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello Ron,

I'm not an expert in Windows, but if this can help a bit:

1. I notice your paths have spaces inside them, which explains why you
quote things. But you have to be careful when you use functions like
io.popen() that take a single string; That Lua function hands its
string straight down to the C function _popen() on Windows, and then
that function uses whatever rules it uses to parse the string back
into an array of arguments.

2. Some of your files have exclamation marks as well (!!) On a POSIX
shell, not even a double-quote shields an exclamation mark enough, it
may be necessary to use single quotes. On Windows I don't know what it
does.

3. I'll simplify from now on the notation:

        luac.exe -l file.lua > file.irp

    This works in the shell because it uses a shell redirect. At least
on Linux, luac *never* sees the ">" as an argument, and all it sees is
["luac.exe", "-l", "file.lua"]. It writes the compiled code to the
default output filename, called "luac.out", and prints to standard
output the listing, but standard output gets redirected to "file.irp".

    I am not sure if the C function _popen(), which io.popen() is
based on Windows, interprets its command string through a shell. If it
*does*, you have to be more careful about quoting, but redirections
work; whereas if it *does not*, then it will not understand the
redirect.

4. You say you use io.popen() with the "w" mode. That's unfortunate,
because you don't need to give luac any standard input and it doesn't
take any, but you *do* need to read the standard output to get the
listing. I recommend the "r" mode.

5. The commands

        luac.exe -l file.lua > file.irp
        luac.exe -l file.lua -o file.irp

    are not equivalent. The former compiles "file.lua" to bytecode in
"luac.out" and the listing to "file.irp". The latter does not even run
because after luac sees the first thing it interprets as a filename
("file.lua"), it assumes everything that follows is a Lua filename to
be compiled as well. "-o" is not a filename.

6. A slight improvement is

        luac.exe -o file.irp -l file.lua

    This will actually run, and compile "file.lua" to bytecode in
"file.irp", overriding the default output filename, and prints to
standard output the listing. But that's not what you wanted; as I
gather it, you want the listing in "file.irp". Unfortunately there is
no way for you to indicate a file to write the listing to.

7. Most appropriate for you is, I believe,

        luac.exe -p -l file.lua

    This uses the "parse only" flag of Luac, and spits out the listing
to standard output. From there, a redirection will take the listing to
wherever you want to have it in the shell, or else io.popen("luac.exe
-p -l file.lua", "r") with the "r" mode will let you capture the
listing from luac's standard output with a :read("*a") . Most
importantly, luac will not create an output file, "luac.out" or
otherwise.

I hope this will be useful to you.


Sincerely,


Olexa Bilaniuk



On Wed, Sep 20, 2023 at 7:47 PM Ron Unknown <qgenesist@hotmail.com> wrote:
>
> I am on windows 11, and use a program called Family Historian https://www.family-historian.co.uk/
>
> Family Historian uses Lua for plugins they will only use from their Plugins folder, not any subfolders.
> Family Historian  version 6.2.7 uses Lua version 5.1 (I do not know the variant beyond that)
> Family Historian  version 7.0.x uses Lua version 5.3 (I do not know the variant beyond that)
>
> I have downloaded the 5.1.5 binaries  in both 32 and 64 bit (there is no difference in the outcome)
> I :gsub('\\', '/') since windows has understood '/' since windows 98 and the '\\' repeats throughout are tiresome.
>
> from a non-elevated command prompt:
> the very first issue I ran into was luac.out access denied, so in Windows/system32 I have an luac.out with full access for all and no longer receive that message.
>
>  "C:/Program Files (x86)/LUAC/5.1/luac5.1.exe" -l "C:/ProgramData/Calico Pie/Family Historian/Plugins/!!XPcall.fh_lua" > "C:/ProgramData/Calico Pie/Family Historian/Plugins/IRP/5.1/!!XPcall.irp"
> this works whether the outfile exists or not on the command line.
>
> so, I am ready to run it through my program:
>  "C:/Program Files (x86)/LUAC/5.1/luac5.1.exe" -l "C:/ProgramData/Calico Pie/Family Historian/Plugins/!!XPcall.fh_lua" > "C:/ProgramData/Calico Pie/Family Historian/Plugins/IRP/5.1/!!XPcall.irp"
> using io.popen(... , 'w')
> result:  No such file or directory
>
> I posit that luac will not understand the redirection pipe:
>  "C:/Program Files (x86)/LUAC/5.1/luac5.1.exe" -l  "C:/ProgramData/Calico Pie/Family Historian/Plugins/!!XPcall.fh_lua" -o "C:/ProgramData/Calico Pie/Family Historian/Plugins/IRP/5.1/!!XPcall.irp"
> result:  No such file or directory
>
> ok, create the file before you output the listing:
> result:  No such file or directory
>
> Yes there is, I just created it.
>
> take it back out to the non-elevated command prompt.
> cannot open -o: No such file or directory
>
> aha, there is some type of error I cannot understand in my command strings when run thru io.popen (or os.execute or laucom) ,  or on the command line,  and the error are from luac.exe
>
> QUESTIONS:
> 1) so what does the command string have to look like?
>  "C:/Program Files (x86)/LUAC/5.1/luac5.1.exe" -l  "C:/ProgramData/Calico Pie/Family Historian/Plugins/!!XPcall.fh_lua" -o "C:/ProgramData/Calico Pie/Family Historian/Plugins/IRP/5.1/!!XPcall.irp"
>
> additonally, under some circumstances I want to create a binary object.
> "C:/Program Files (x86)/LUAC/5.1/luac5.1.exe" -t -s  "C:/ProgramData/Calico Pie/Family Historian/Plugins/QSRC/QSYS.lua" -o "C:/ProgramData/Calico Pie/Family Historian/Plugins/QSYS.lua"  I understand that I may not use -t on 5.1 compiles.
>
> result:  No such file or directory
> 2, 3) so what does that command string have to look like, and do I have to 'wb' for this?
>
> 4_) do I need to create empty supplied outfiles, or does luac create them (or overwrite them if they exist)?
>
> I can supply the lua code (it uses several requires that I would have to supply and it is geared only to Family Historian paths, etc) but I do not feel the errors are in the general code, just the assembling of the command string)
>
> Thank you,
> Ronald Melby
>