3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Claus Hentschel
7 * \author Enrico Forestieri
9 * Full author contact details are available in file CREDITS.
11 * This is the wrapper program for LyX/Cygwin. Using this wrapper no
12 * DOS window will be present when running LyX from the Windows GUI.
13 * The bad side of this: no error output can be seen ;-)
15 * It launches the real binary using the native Windows GUI.
25 #include <cygwin/version.h>
26 #include <sys/cygwin.h>
29 void convert_to_posix_path(char const * from, char *to)
31 #if CYGWIN_VERSION_DLL_MAJOR >= 1007
32 cygwin_conv_path(CCP_WIN_A_TO_POSIX | CCP_RELATIVE, from, to, PATH_MAX);
34 cygwin_conv_to_posix_path(from, to);
38 int main (int argc, char **argv, char **environ)
42 char posixpath[PATH_MAX];
43 char cmd[4096] = PACKAGE " ";
44 char const *nargs[5] = {
45 "/bin/bash", "--login",
53 int lyxfile = (s = strrchr(argv[i], '.'))
54 && strcasecmp(s, ".lyx") == 0;
55 /* Add initial quote */
57 convert_to_posix_path(argv[i], posixpath) ;
58 /* Hack to account for shares */
59 if (lyxfile && argv[i][0] == '\\' && argv[i][1] != '\\')
61 /* add the argument */
62 strcat(cmd, posixpath);
63 /* add closing quote */
65 if (!done && lyxfile && (s = strrchr(posixpath,'/'))) {
67 if (setenv("CDPATH", posixpath, 1) == 0)
73 strcat(cmd, "</dev/null 1>/dev/null 2>&1");
75 /* fprintf(stderr , "Command is: |%s|\n", cmd); */
76 /* ensure bash reads our global env changes */
77 putenv("BASH_ENV=" LYX_ABS_INSTALLED_DATADIR "/lyxprofile") ;
78 /* exec sub command */
79 spawnv(_P_NOWAIT, "/bin/bash", nargs);
80 /* exit with no error */