Hi,
When Geany is started from the Gnome menu it doesn't get environment
variables set in .profile, .bashrc etc. Other window managers seem
ok.
This means that builds don't see CFLAGS, python executes don't see
PYTHONPATH etc :-(
Although builds and executes run in shells, a non-interactive shell
does not load any startup files.
The attached patch adds the option (-l) to run the build and execute
shells as login shells which will load startup files.
Two hidden prefs build_in_login_shell and exec_in_login_shell allow
you to disable this for builds or executes respectively if running
your startup scripts causes some problem.
Cheers
Lex
Index: src/build.c
===================================================================
--- src/build.c (revision 5410)
+++ src/build.c (working copy)
@@ -70,6 +70,8 @@
GeanyBuildInfo build_info = {GEANY_GBG_FT, 0, 0, NULL, GEANY_FILETYPES_NONE, NULL, 0};
+GeanyBuildPreferences build_prefs;
+
static gchar *current_dir_entered = NULL;
typedef struct RunInfo
@@ -703,11 +705,22 @@
#ifdef G_OS_WIN32
argv = g_strsplit(cmd_string, " ", 0);
#else
- argv = g_new0(gchar *, 4);
- argv[0] = g_strdup("/bin/sh");
- argv[1] = g_strdup("-c");
- argv[2] = cmd_string;
- argv[3] = NULL;
+ argv = g_new0(gchar *, 5);
+ if (build_prefs.build_in_login_shell)
+ {
+ argv[0] = g_strdup("/bin/sh");
+ argv[1] = g_strdup("-l");
+ argv[2] = g_strdup("-c");
+ argv[3] = cmd_string;
+ argv[4] = NULL;
+ }
+ else
+ {
+ argv[0] = g_strdup("/bin/sh");
+ argv[1] = g_strdup("-c");
+ argv[2] = cmd_string;
+ argv[3] = NULL;
+ }
#endif
utf8_cmd_string = utils_get_utf8_from_locale(cmd_string);
@@ -953,7 +966,14 @@
}
#else
argv[term_argv_len ] = g_strdup("-e");
- argv[term_argv_len + 1] = g_strconcat("/bin/sh ", RUN_SCRIPT_CMD, NULL);
+ if (build_prefs.exec_in_login_shell)
+ {
+ argv[term_argv_len + 1] = g_strconcat("/bin/sh -l ", RUN_SCRIPT_CMD, NULL);
+ }
+ else
+ {
+ argv[term_argv_len + 1] = g_strconcat("/bin/sh ", RUN_SCRIPT_CMD, NULL);
+ }
#endif
argv[term_argv_len + 2] = NULL;
Index: src/build.h
===================================================================
--- src/build.h (revision 5410)
+++ src/build.h (working copy)
@@ -155,6 +155,14 @@
gchar **nonfileregexstr;
} BuildDestination;
+/* The build preferences */
+typedef struct GeanyBuildPreferences {
+ gboolean build_in_login_shell;
+ gboolean exec_in_login_shell;
+} GeanyBuildPreferences;
+
+extern GeanyBuildPreferences build_prefs;
+
/* opaque pointers returned from build functions and passed back to them */
typedef struct BuildTableFields *BuildTableData;
Index: src/keyfile.c
===================================================================
--- src/keyfile.c (revision 5410)
+++ src/keyfile.c (working copy)
@@ -189,6 +189,10 @@
"complete_snippets_whilst_editing", FALSE);
stash_group_add_boolean(group, &file_prefs.use_safe_file_saving,
"use_safe_file_saving", FALSE);
+ stash_group_add_boolean(group, &build_prefs.build_in_login_shell,
+ "build_in_login_shell", TRUE);
+ stash_group_add_boolean(group, &build_prefs.exec_in_login_shell,
+ "exec_in_login_shell", TRUE);
/* for backwards-compatibility */
stash_group_add_integer(group, &editor_prefs.indentation->hard_tab_width,
"indent_hard_tab_width", 8);
_______________________________________________
Geany-devel mailing list
[email protected]
http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel