Open s-ol opened 8 years ago
I monkey-patched it very badly with this:
--- src/loslib.c.orig 2008-01-18 17:38:18.000000000 +0100
+++ src/loslib.c 2016-10-15 18:23:37.178565100 +0200
@@ -36,6 +36,10 @@
static int os_execute (lua_State *L) {
+ lua_pushstring(L, "%WD%\\..\\..\\mingw32 bash -c \"");
+ lua_insert(L, -2);
+ lua_pushstring(L, "\"");
+ lua_concat(L, 3);
lua_pushinteger(L, system(luaL_optstring(L, 1, NULL)));
return 1;
}
--- src/liolib.c.orig 2010-05-14 17:33:51.000000000 +0200
+++ src/liolib.c 2016-10-15 18:23:37.181581800 +0200
@@ -172,6 +172,10 @@
** correct __close for 'popen' files
*/
static int io_popen (lua_State *L) {
+ lua_pushstring(L, "%WD%\\..\\..\\mingw32 bash -c \"");
+ lua_insert(L, -2);
+ lua_pushstring(L, "\"");
+ lua_concat(L, 3);
const char *filename = luaL_checkstring(L, 1);
const char *mode = luaL_optstring(L, 2, "r");
FILE **pf = newfile(L);
but not only doesn't it escape the command string properly, it also opens a new shell window, takes ages and doesn't provide any output where it should. Is there a way not to open a new shell window?
well duh, and it's way easier:
--- src/loslib.c.orig 2008-01-18 17:38:18.000000000 +0100
+++ src/loslib.c 2016-10-15 18:23:37.178565100 +0200
@@ -36,6 +36,10 @@
static int os_execute (lua_State *L) {
+ lua_pushstring(L, "%WD%\\bash -c \"");
+ lua_insert(L, -2);
+ lua_pushstring(L, "\"");
+ lua_concat(L, 3);
lua_pushinteger(L, system(luaL_optstring(L, 1, NULL)));
return 1;
}
--- src/liolib.c.orig 2010-05-14 17:33:51.000000000 +0200
+++ src/liolib.c 2016-10-15 18:23:37.181581800 +0200
@@ -172,6 +172,10 @@
** correct __close for 'popen' files
*/
static int io_popen (lua_State *L) {
+ lua_pushstring(L, "%WD%\\bash -c \"");
+ lua_insert(L, -2);
+ lua_pushstring(L, "\"");
+ lua_concat(L, 3);
const char *filename = luaL_checkstring(L, 1);
const char *mode = luaL_optstring(L, 2, "r");
FILE **pf = newfile(L);
...buuuuut the whole io library still uses the wrong paths.
Well I'm not be able to fix it myself because of lack of time. Try do it yourself or ask someone
Since you are spawning a bash
instance to do the lifting can you not use the cygpath
as well to tweak the paths to the wanted form?
$ cygpath --help
Usage: cygpath (-d|-m|-u|-w|-t TYPE) [-f FILE] [OPTION]... NAME...
cygpath [-c HANDLE]
cygpath [-ADHOPSW]
cygpath [-F ID]
Convert Unix and Windows format paths, or output system path information
Output type options:
-d, --dos print DOS (short) form of NAMEs (C:\PROGRA~1\)
-m, --mixed like --windows, but with regular slashes (C:/WINNT)
-M, --mode report on mode of file (binmode or textmode)
-u, --unix (default) print Unix form of NAMEs (/cygdrive/c/winnt)
-w, --windows print Windows form of NAMEs (C:\WINNT)
-t, --type TYPE print TYPE form: 'dos', 'mixed', 'unix', or 'windows'
Path conversion options:
-a, --absolute output absolute path
-l, --long-name print Windows long form of NAMEs (with -w, -m only)
-p, --path NAME is a PATH list (i.e., '/bin:/usr/bin')
-U, --proc-cygdrive Emit /proc/cygdrive path instead of cygdrive prefix
when converting Windows path to UNIX path.
-s, --short-name print DOS (short) form of NAMEs (with -w, -m only)
-C, --codepage CP print DOS, Windows, or mixed pathname in Windows
codepage CP. CP can be a numeric codepage identifier,
or one of the reserved words ANSI, OEM, or UTF8.
If this option is missing, cygpath defaults to the
character set defined by the current locale.
System information:
-A, --allusers use `All Users' instead of current user for -D, -O, -P
-D, --desktop output `Desktop' directory and exit
-H, --homeroot output `Profiles' directory (home root) and exit
-O, --mydocs output `My Documents' directory and exit
-P, --smprograms output Start Menu `Programs' directory and exit
-S, --sysdir output system directory and exit
-W, --windir output `Windows' directory and exit
-F, --folder ID output special folder with numeric ID and exit
Other options:
-f, --file FILE read FILE for input; use - to read from STDIN
-o, --option read options from FILE as well (for use with --file)
-c, --close HANDLE close HANDLE (for use in captured process)
-i, --ignore ignore missing argument
-h, --help output usage information and exit
-V, --version output version information and exit
Still a problem, os.execute
is still incorrectly interpreted via Windows CMD instead of Bash.
this makes it very hard to run any lua based projects that build other things (like luarocks) because they must use windows
cmd.exe
syntax but somehow still work within the MSYS directory strucutre and use the mingw buildchain.