[Xfce4-commits] [apps/xfce4-terminal] 01/01: Use OSC 7 to get current working directory

noreply at xfce.org noreply at xfce.org
Fri Oct 6 17:23:54 CEST 2017


This is an automated email from the git hooks/post-receive script.

f   2   4   0   4       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/xfce4-terminal.

commit ff1419604d928c37bef10889e10ab2657cc091d3
Author: Igor <f2404 at yandex.ru>
Date:   Fri Oct 6 11:22:46 2017 -0400

    Use OSC 7 to get current working directory
    
    Working directory can be retrieved from vte if vte-2.91.sh has been sourced.
    Fixes #13902
---
 terminal/terminal-screen.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/terminal/terminal-screen.c b/terminal/terminal-screen.c
index 3e0a370..c49d0b2 100644
--- a/terminal/terminal-screen.c
+++ b/terminal/terminal-screen.c
@@ -832,6 +832,14 @@ terminal_screen_get_child_environment (TerminalScreen *screen)
           || strcmp (*p, "TERM") == 0)
         continue;
 
+      /* copy working directory to $PWD, to preserve symlinks
+       * see https://bugzilla.gnome.org/show_bug.cgi?id=758452 */
+      if (strcmp (*p, "PWD") == 0)
+        {
+          result[n++] = g_strconcat (*p, "=", screen->working_directory, NULL);
+          continue;
+        }
+
       /* copy the variable */
       value = g_getenv (*p);
       if (G_LIKELY (value != NULL))
@@ -2034,14 +2042,22 @@ terminal_screen_get_title (TerminalScreen *screen)
 const gchar*
 terminal_screen_get_working_directory (TerminalScreen *screen)
 {
-  gchar  buffer[4096 + 1];
-  gchar *file;
-  gchar *cwd;
-  gint   length;
+  gchar        buffer[4096 + 1];
+  gchar       *file;
+  gchar       *cwd;
+  const gchar *uri;
+  gint         length;
 
   terminal_return_val_if_fail (TERMINAL_IS_SCREEN (screen), NULL);
 
-  if (screen->pid >= 0)
+  /* try to use vte functionality first: see bug #13902 */
+  uri = vte_terminal_get_current_directory_uri (VTE_TERMINAL (screen->terminal));
+  if (uri != NULL)
+    {
+      g_free (screen->working_directory);
+      screen->working_directory = g_filename_from_uri (uri, NULL, NULL);
+    }
+  else if (screen->pid >= 0)
     {
       /* make sure that we use linprocfs on all systems */
 #if defined(__FreeBSD__)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list