anjuta r3999 - in trunk: . libanjuta plugins/debug-manager plugins/run-program
- From: sgranjoux svn gnome org
- To: svn-commits-list gnome org
- Subject: anjuta r3999 - in trunk: . libanjuta plugins/debug-manager plugins/run-program
- Date: Tue, 10 Jun 2008 20:52:29 +0000 (UTC)
Author: sgranjoux
Date: Tue Jun 10 20:52:29 2008
New Revision: 3999
URL: http://svn.gnome.org/viewvc/anjuta?rev=3999&view=rev
Log:
* libanjuta/anjuta-utils.c,
libanjuta/anjuta-utils.h,
plugins/debug-manager/start.c,
plugins/run-program/execute.c:
Copy libgnome deprecated gnome_util_user_shell into libanjuta
Modified:
trunk/ChangeLog
trunk/libanjuta/anjuta-utils.c
trunk/libanjuta/anjuta-utils.h
trunk/plugins/debug-manager/start.c
trunk/plugins/run-program/execute.c
Modified: trunk/libanjuta/anjuta-utils.c
==============================================================================
--- trunk/libanjuta/anjuta-utils.c (original)
+++ trunk/libanjuta/anjuta-utils.c Tue Jun 10 20:52:29 2008
@@ -44,6 +44,9 @@
#include <unistd.h>
#include <stdio.h>
#include <string.h>
+#ifndef G_OS_WIN32
+#include <pwd.h>
+#endif
#include <glib/gi18n.h>
#include <glib.h>
@@ -799,6 +802,74 @@
return TRUE;
}
+/**
+ * anjuta_util_user_shell:
+ *
+ * Retrieves the user's preferred shell.
+ *
+ * Returns: A newly allocated string that is the path to the shell.
+ */
+/* copied from deprecated gnome_util_user_shell in libgnome */
+char *
+anjuta_util_user_shell (void)
+{
+#ifndef G_OS_WIN32
+ struct passwd *pw;
+ int i;
+ const char *shell;
+ const char shells [][14] = {
+ /* Note that on some systems shells can also
+ * be installed in /usr/bin */
+ "/bin/bash", "/usr/bin/bash",
+ "/bin/zsh", "/usr/bin/zsh",
+ "/bin/tcsh", "/usr/bin/tcsh",
+ "/bin/ksh", "/usr/bin/ksh",
+ "/bin/csh", "/bin/sh"
+ };
+
+ if (geteuid () == getuid () &&
+ getegid () == getgid ()) {
+ /* only in non-setuid */
+ if ((shell = g_getenv ("SHELL"))){
+ if (access (shell, X_OK) == 0) {
+ return g_strdup (shell);
+ }
+ }
+ }
+ pw = getpwuid(getuid());
+ if (pw && pw->pw_shell) {
+ if (access (pw->pw_shell, X_OK) == 0) {
+ return g_strdup (pw->pw_shell);
+ }
+ }
+
+ for (i = 0; i != G_N_ELEMENTS (shells); i++) {
+ if (access (shells [i], X_OK) == 0) {
+ return g_strdup (shells[i]);
+ }
+ }
+
+ /* If /bin/sh doesn't exist, your system is truly broken. */
+ abort ();
+
+ /* Placate compiler. */
+ return NULL;
+#else
+ /* g_find_program_in_path() always looks also in the Windows
+ * and System32 directories, so it should always find either cmd.exe
+ * or command.com.
+ */
+ char *retval = g_find_program_in_path ("cmd.exe");
+
+ if (retval == NULL)
+ retval = g_find_program_in_path ("command.com");
+
+ g_assert (retval != NULL);
+
+ return retval;
+#endif
+}
+
pid_t
anjuta_util_execute_shell (const gchar *dir, const gchar *command)
{
@@ -807,7 +878,7 @@
g_return_val_if_fail (command != NULL, -1);
- shell = gnome_util_user_shell ();
+ shell = anjuta_util_user_shell ();
pid = fork();
if (pid == 0)
{
Modified: trunk/libanjuta/anjuta-utils.h
==============================================================================
--- trunk/libanjuta/anjuta-utils.h (original)
+++ trunk/libanjuta/anjuta-utils.h Tue Jun 10 20:52:29 2008
@@ -104,6 +104,7 @@
gint length);
gboolean anjuta_util_create_dir (const gchar * d);
+char * anjuta_util_user_shell (void);
pid_t anjuta_util_execute_shell (const gchar *dir, const gchar *command);
gchar* anjuta_util_escape_quotes(const gchar* str);
Modified: trunk/plugins/debug-manager/start.c
==============================================================================
--- trunk/plugins/debug-manager/start.c (original)
+++ trunk/plugins/debug-manager/start.c Tue Jun 10 20:52:29 2008
@@ -45,8 +45,6 @@
#include <libgnomevfs/gnome-vfs-mime-utils.h>
#include <libgnomevfs/gnome-vfs-utils.h>
-#include <gnome.h>
-
#include <glade/glade-xml.h>
#include <errno.h>
@@ -585,7 +583,7 @@
#else
cmd = g_strconcat ("ps axw -H -o pid,user,start_time,args > ", tmp, NULL);
#endif
- shell = gnome_util_user_shell ();
+ shell = anjuta_util_user_shell ();
ch_pid = fork ();
if (ch_pid == 0)
{
Modified: trunk/plugins/run-program/execute.c
==============================================================================
--- trunk/plugins/run-program/execute.c (original)
+++ trunk/plugins/run-program/execute.c Tue Jun 10 20:52:29 2008
@@ -276,7 +276,7 @@
new_env[i] = NULL;
/* Run user program using in a shell */
- user_shell = gnome_util_user_shell ();
+ user_shell = anjuta_util_user_shell ();
argv[0] = user_shell;
argv[1] = "-c";
argv[2] = cmd;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]