Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Mon, 06 Mar 2023 21:29:13 UTC Commit: 760db618cef01e60ca11c2040e9f4c8c2937d7e0 https://github.com/geany/geany-osx/commit/760db618cef01e60ca11c2040e9f4c8c29...
Log Message: ----------- Update patch so it applies with current glade file
Modified Paths: -------------- geany.modules geany_patches/01git-geany_config_shell.patch
Modified: geany.modules 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -111,7 +111,7 @@ checkoutdir="geany-git" revision="master" > <!-- This patch corresponds to https://github.com/geany/geany/pull/2363 --> - <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/01-geany_config_shell.patch" strip="1" /> + <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/01git-geany_config_shell.patch" strip="1" /> <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/02-geany_scintilla_candidate_window_pos.patch" strip="1" /> <patch file="https://github.com/geany/geany-osx/raw/master/geany_patches/03-geany_vte_login_shell.patch" strip="1" /> </branch>
Modified: geany_patches/01git-geany_config_shell.patch 254 lines changed, 254 insertions(+), 0 deletions(-) =================================================================== @@ -0,0 +1,254 @@ +From 2981b0761b343e0eb49ab36f01bf37c4acec5245 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ji=C5=99=C3=AD=20Techet?= techet@gmail.com +Date: Sat, 9 Nov 2019 10:46:39 -0800 +Subject: [PATCH 1/2] Allow configuring shell used for build commands + +Currently there is a problem when users use a different shell than sh/bash +and configure their environment in the config file of the given shell. +This config file isn't loaded by Geany because Geany always uses sh +in a non-login non-interactive way. + +This patch tries to solve the problem by allowing users to specify the +shell they want to use for launching build commands. In order to make +shells load their config files, the shells are run as login non-interactive +shells because non-login non-interactive shells like sh/bash don't load +configuration from any files. Unfortunately csh/tcsh don't allow us to be +run as login and use the -c option simultaneously so these shells aren't +started as login shells. + +Running shells as login is absolutely necessary on macOS even for sh/bash. +While on linux display managers typically source .profile upon login, +this doesn't happen on macOS and the only way to get the environment loaded +is to run shells as login. + +There are some places where /bin/sh can still be used. One of them is +the execute command. When configured to use VTE for execution, we already +have the environment set up by the shell in VTE so we don't need to do any +other work. When configured to use external terminal for running, the +terminal is run as non-login interactive so it should load its +configuration too. + +I kept the printing command to use /bin/sh because either the code used +for the build command would have to be duplicated there or somehow +factored-out and it doesn't seem to be worth the work for this simple +case where only /usr/bin/lpr is called. + +This patch has been tested with the following shells: +sh, bash, dash, ksh, zsh, csh, tcsh, fish, ion +--- + data/geany.glade | 59 +++++++++++++++++++++++++++++++++++++++++++++++- + src/build.c | 14 ++++++++++-- + src/keyfile.c | 7 ++++++ + src/prefs.c | 10 ++++++++ + src/prefs.h | 1 + + 5 files changed, 88 insertions(+), 3 deletions(-) + +diff --git a/data/geany.glade b/data/geany.glade +index 3864a0ad1..79cf7c4b9 100644 +--- a/data/geany.glade ++++ b/data/geany.glade +@@ -4798,7 +4798,7 @@ + <object class="GtkTable" id="table1"> + <property name="visible">True</property> + <property name="can-focus">False</property> +- <property name="n-rows">3</property> ++ <property name="n-rows">4</property> + <property name="n-columns">3</property> + <property name="column-spacing">6</property> + <property name="row-spacing">3</property> +@@ -4960,6 +4960,63 @@ + <property name="y-options"/> + </packing> + </child> ++ <child> ++ <object class="GtkLabel" id="label27"> ++ <property name="visible">True</property> ++ <property name="can-focus">False</property> ++ <property name="xalign">0</property> ++ <property name="label" translatable="yes">Shell:</property> ++ <property name="mnemonic-widget">entry-grep</property> ++ </object> ++ <packing> ++ <property name="top-attach">3</property> ++ <property name="bottom-attach">4</property> ++ <property name="x-options">GTK_FILL</property> ++ <property name="y-options"/> ++ </packing> ++ </child> ++ <child> ++ <object class="GtkEntry" id="entry_shell1"> ++ <property name="visible">True</property> ++ <property name="can-focus">True</property> ++ <property name="tooltip-text" translatable="yes">Shell used for build commands (useful to get environment set up from the shell's config files)</property> ++ <property name="invisible-char">•</property> ++ <property name="invisible-char-set">True</property> ++ <property name="primary-icon-activatable">False</property> ++ <property name="secondary-icon-activatable">False</property> ++ <property name="primary-icon-sensitive">True</property> ++ <property name="secondary-icon-sensitive">True</property> ++ </object> ++ <packing> ++ <property name="left-attach">1</property> ++ <property name="right-attach">2</property> ++ <property name="top-attach">3</property> ++ <property name="bottom-attach">4</property> ++ <property name="y-options"/> ++ </packing> ++ </child> ++ <child> ++ <object class="GtkButton" id="button_shell"> ++ <property name="visible">True</property> ++ <property name="can-focus">True</property> ++ <property name="receives-default">False</property> ++ <child> ++ <object class="GtkImage" id="image7"> ++ <property name="visible">True</property> ++ <property name="can-focus">False</property> ++ <property name="stock">gtk-open</property> ++ </object> ++ </child> ++ </object> ++ <packing> ++ <property name="left-attach">2</property> ++ <property name="right-attach">3</property> ++ <property name="top-attach">3</property> ++ <property name="bottom-attach">4</property> ++ <property name="x-options">GTK_FILL</property> ++ <property name="y-options"/> ++ </packing> ++ </child> + </object> + <packing> + <property name="expand">False</property> +diff --git a/src/build.c b/src/build.c +index 4c9f4ebb2..996758d80 100644 +--- a/src/build.c ++++ b/src/build.c +@@ -772,10 +772,11 @@ static gchar *build_replace_placeholder(const GeanyDocument *doc, const gchar *s + static void build_spawn_cmd(GeanyDocument *doc, const gchar *cmd, const gchar *dir) + { + GError *error = NULL; +- gchar *argv[] = { "/bin/sh", "-c", NULL, NULL }; ++ gchar *argv[] = { tool_prefs.shell_cmd, "-l", "-c", NULL, NULL }; + gchar *working_dir; + gchar *utf8_working_dir; + gchar *cmd_string; ++ gchar *shell = NULL; + + g_return_if_fail(doc == NULL || doc->is_valid); + +@@ -799,8 +800,16 @@ static void build_spawn_cmd(GeanyDocument *doc, const gchar *cmd, const gchar *d + + #ifdef G_OS_UNIX + cmd_string = utils_get_locale_from_utf8(cmd); +- argv[2] = cmd_string; + cmd = NULL; /* under Unix, use argv to start cmd via sh for compatibility */ ++ shell = g_path_get_basename(tool_prefs.shell_cmd); ++ if (g_strcmp0(shell, "csh") == 0 || g_strcmp0(shell, "tcsh") == 0) ++ { ++ /* csh and tcsh don't support -l together with -c so don't use it */ ++ argv[1] = "-c"; ++ argv[2] = cmd_string; ++ } ++ else ++ argv[3] = cmd_string; + #else + /* Expand environment variables like %blah%. */ + cmd_string = win32_expand_environment_variables(cmd); +@@ -825,6 +834,7 @@ static void build_spawn_cmd(GeanyDocument *doc, const gchar *cmd, const gchar *d + + g_free(working_dir); + g_free(cmd_string); ++ g_free(shell); + } + + +diff --git a/src/keyfile.c b/src/keyfile.c +index a5f6e9dfd..d4daa0b2f 100644 +--- a/src/keyfile.c ++++ b/src/keyfile.c +@@ -93,6 +93,11 @@ + #endif + #define GEANY_DEFAULT_TOOLS_PRINTCMD "lpr" + #define GEANY_DEFAULT_TOOLS_GREP "grep" ++#ifdef __APPLE__ ++# define GEANY_DEFAULT_TOOLS_SHELL "/bin/bash" ++#else ++# define GEANY_DEFAULT_TOOLS_SHELL "/bin/sh" ++#endif + #define GEANY_DEFAULT_MRU_LENGTH 10 + #define GEANY_TOGGLE_MARK "~ " + #define GEANY_MAX_AUTOCOMPLETE_WORDS 30 +@@ -523,6 +528,7 @@ static void save_dialog_prefs(GKeyFile *config) + g_key_file_set_string(config, "tools", "terminal_cmd", tool_prefs.term_cmd ? tool_prefs.term_cmd : ""); + g_key_file_set_string(config, "tools", "browser_cmd", tool_prefs.browser_cmd ? tool_prefs.browser_cmd : ""); + g_key_file_set_string(config, "tools", "grep_cmd", tool_prefs.grep_cmd ? tool_prefs.grep_cmd : ""); ++ g_key_file_set_string(config, "tools", "shell_cmd", tool_prefs.shell_cmd ? tool_prefs.shell_cmd : ""); + g_key_file_set_string(config, PACKAGE, "context_action_cmd", tool_prefs.context_action_cmd); + + /* build menu */ +@@ -965,6 +971,7 @@ static void load_dialog_prefs(GKeyFile *config) + tool_prefs.term_cmd = cmd; + tool_prefs.browser_cmd = utils_get_setting_string(config, "tools", "browser_cmd", GEANY_DEFAULT_TOOLS_BROWSER); + tool_prefs.grep_cmd = utils_get_setting_string(config, "tools", "grep_cmd", GEANY_DEFAULT_TOOLS_GREP); ++ tool_prefs.shell_cmd = utils_get_setting_string(config, "tools", "shell_cmd", GEANY_DEFAULT_TOOLS_SHELL); + + tool_prefs.context_action_cmd = utils_get_setting_string(config, PACKAGE, "context_action_cmd", ""); + +diff --git a/src/prefs.c b/src/prefs.c +index 5d1b5fc97..f43f83619 100644 +--- a/src/prefs.c ++++ b/src/prefs.c +@@ -683,6 +683,8 @@ static void prefs_init_dialog(void) + if (tool_prefs.grep_cmd) + gtk_entry_set_text(GTK_ENTRY(ui_lookup_widget(ui_widgets.prefs_dialog, "entry_grep")), tool_prefs.grep_cmd); + ++ if (tool_prefs.shell_cmd) ++ gtk_entry_set_text(GTK_ENTRY(ui_lookup_widget(ui_widgets.prefs_dialog, "entry_shell1")), tool_prefs.shell_cmd); + + /* Template settings */ + widget = ui_lookup_widget(ui_widgets.prefs_dialog, "entry_template_developer"); +@@ -1160,6 +1162,9 @@ on_prefs_dialog_response(GtkDialog *dialog, gint response, gpointer user_data) + g_free(tool_prefs.grep_cmd); + tool_prefs.grep_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); + ++ widget = ui_lookup_widget(ui_widgets.prefs_dialog, "entry_shell1"); ++ g_free(tool_prefs.shell_cmd); ++ tool_prefs.shell_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget))); + + /* Template settings */ + widget = ui_lookup_widget(ui_widgets.prefs_dialog, "entry_template_developer"); +@@ -1727,6 +1732,7 @@ void prefs_show_dialog(void) + "entry_com_term", + "entry_browser", + "entry_grep", ++ "entry_shell1", + "entry_contextaction", + "entry_template_developer", + "entry_template_initial", +@@ -1787,6 +1793,10 @@ void prefs_show_dialog(void) + NULL, + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_ENTRY(ui_lookup_widget(ui_widgets.prefs_dialog, "entry_grep"))); ++ ui_setup_open_button_callback(ui_lookup_widget(ui_widgets.prefs_dialog, "button_shell"), ++ NULL, ++ GTK_FILE_CHOOSER_ACTION_OPEN, ++ GTK_ENTRY(ui_lookup_widget(ui_widgets.prefs_dialog, "entry_shell1"))); + + /* tools commands */ + ui_setup_open_button_callback(ui_lookup_widget(ui_widgets.prefs_dialog, "button_contextaction"), +diff --git a/src/prefs.h b/src/prefs.h +index dcf33a502..aedfcb0f8 100644 +--- a/src/prefs.h ++++ b/src/prefs.h +@@ -49,6 +49,7 @@ typedef struct GeanyToolPrefs + gchar *term_cmd; /**< terminal emulator command */ + gchar *grep_cmd; /**< grep command */ + gchar *context_action_cmd; /**< context action command */ ++ gchar *shell_cmd; /**< shell used for running commands */ + } + GeanyToolPrefs; + +-- +2.17.1 +
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).