Open GoogleCodeExporter opened 9 years ago
so here what happen
when you bundle an *.abc file with a shell.exe you are basically creating a
projector
when the shell execute it tries to discover if it is in "projector mode" or
"shell mode"
and here without the ".exe" extension the shell fail to see it is in "projector
mode"
so it runs the regular shell command (and end up showing the usage informations)
the problem is situated here
http://code.google.com/p/redtamarin/source/browse/trunk/shell/avmshell.cpp#695
apparently running an executable without the ".exe" extension does not fill the
argv[0] value,
and because argv[0] is NULLL, then the redshell fail to reckonize it is a
projector
I ll make some tests with something like
{{{
char *Path;
GetModuleFileName(NULL, Path,MAX_PATH);
printf("%s\n", Path);
}}}
see if it gives better result under Windows
also as an alternative if you run under cygwin there is no issues (eg. argv[0]
is found)
see the attached screenshot.
Original comment by zwetan
on 18 Jul 2011 at 12:51
Attachments:
Original comment by zwetan
on 28 Oct 2011 at 1:31
just gave redtamarin a spin - very nice work.
i've noticed this issue, but i'm not exactly sure why it happens, as the
windows default shell should always populate argv[0] with the call (being
"a.exe" or simply "a"); also to my knowledge the value of argc should be >=1 on
DOS/CMD/NTVDM. on the other hand cygwi/msys with bash/sh should populate it
with a full path.
> apparently running an executable without the ".exe" extension does not fill
the
> argv[0] value, and because argv[0] is NULLL, then the redshell fail to
reckonize
> it is a projector
as mentioned above i cannot confirm this, but mind that the c entry point
arguments are shell specific and if you decide to port your code to a not so
common OS, its shell might not even allow arguments (argc = 0, *argv = NULL).
if you are mainly targeting popular OS, arguments should work on such (thus a
puzzle for this specific issue).
i haven't compiled your code since there are a bit too much dependencies for
me: ant, python, jre etc., but here is a simple test with argv[0] /
GetModuleFileName() for windows:
// -------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define STRIP_PATH(buffer, filename) \
(filename) = strrchr((buffer), '\\'); \
if ((filename)) \
(filename)++; \
else \
(filename) = (buffer)
int main(int argc, char *argv[])
{
const char ext_exe[] = ".exe\0";
char buffer[MAX_PATH] = {0};
char *filename;
short i;
if (!(*argv))
{
GetModuleFileName(NULL, buffer, MAX_PATH);
STRIP_PATH(buffer, filename);
printf("no arguments, %d, %s\n", argc, filename);
}
else
{
strcpy((char *)buffer, argv[0]);
i = -1;
while (buffer[++i])
buffer[i] = tolower(buffer[i]);
if (!strstr((char *)buffer, ext_exe))
strcat(buffer, ext_exe);
STRIP_PATH(buffer, filename);
printf("has argumens, %d, %s\n", argc, filename);
}
return 0;
}
// -------------------------------------------------------------------
lubomir
--
Original comment by neolit123
on 13 Jun 2012 at 12:53
I will investigate that further with the basic command prompt and cygwin under
Windows
Original comment by zwetan
on 20 Nov 2013 at 5:16
Original issue reported on code.google.com by
thegar...@gmail.com
on 17 Jul 2011 at 5:02