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 <sys/cygwin.h>
28 int main (int argc, char **argv, char **environ)
32 char posixpath[PATH_MAX];
33 char cmd[4096] = PACKAGE " ";
34 char const *nargs[5] = {
35 "/bin/bash", "--login",
43 int lyxfile = (s = strrchr(argv[i], '.'))
44 && strcasecmp(s, ".lyx") == 0;
45 /* Add initial quote */
47 cygwin_conv_to_posix_path(argv[i], posixpath) ;
48 /* Hack to account for shares */
49 if (lyxfile && argv[i][0] == '\\' && argv[i][1] != '\\')
51 /* add the argument */
52 strcat(cmd, posixpath);
53 /* add closing quote */
55 if (!done && lyxfile && (s = strrchr(posixpath,'/'))) {
57 if (setenv("CDPATH", posixpath, 1) == 0)
63 strcat(cmd, "</dev/null 1>/dev/null 2>&1");
65 /* fprintf(stderr , "Command is: |%s|\n", cmd); */
66 /* ensure bash reads our global env changes */
67 putenv("BASH_ENV=/etc/lyxprofile") ;
68 /* exec sub command */
69 spawnv(_P_NOWAIT, "/bin/bash", nargs);
70 /* exit with no error */