[vte] vte.sh: Use the vte-urlencode utility



commit 115db9c2b4d07ab7bcd98c287c39854649bd2750
Author: Carlos Santos <casantos redhat com>
Date:   Wed Jan 22 18:06:28 2020 +0100

    vte.sh: Use the vte-urlencode utility
    
    Drop the __vte_urlencode function and use the vte-urlencode-cwd utility,
    instead of it, in __vte_osc7.
    
    Also call __vte_osc7 directly in __vte_prompt_command, instead of in a
    subshell, avoiding an extra fork.
    
    Drop the __vte_urlencode test, since the function does not exist anymore
    and vte-urlencode-cwd has its own test.
    
    https://gitlab.gnome.org/GNOME/vte/issues/206

 src/meson.build           | 32 +++++---------------
 src/test-vte-sh.sh        | 75 -----------------------------------------------
 src/{vte.sh => vte.sh.in} | 24 +++------------
 3 files changed, 11 insertions(+), 120 deletions(-)
---
diff --git a/src/meson.build b/src/meson.build
index 85312ab0..78dba0c5 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -508,11 +508,6 @@ foreach test: test_units
   )
 endforeach
 
-test_script_env = test_env + [
-  # srcdir is needed for the vte.sh test
-  'srcdir=@0@'.format(meson.current_source_dir()),
-]
-
 test_scripts = [
   ['doc syntax', 'check-doc-syntax.sh'],
 ]
@@ -521,24 +516,6 @@ foreach test: test_scripts
   test(
     test[0],
     files(test[1]),
-    env: test_script_env,
-  )
-endforeach
-
-test_scripts_interactive = [
-  ['vte.sh', 'test-vte-sh.sh', files('vte.sh')],
-]
-
-# vte.sh needs to be run in an interactive shell, but there is way to
-# specify that in test(), except by running bash itself explicitly with -i.
-bash = find_program('bash')
-
-foreach test: test_scripts_interactive
-  test(
-    test[0],
-    bash,
-    args: ['-i', files(test[1]), test[2]],
-    env: test_script_env,
   )
 endforeach
 
@@ -556,8 +533,13 @@ endforeach
 
 # Shell integration
 
-install_data(
-  'vte.sh',
+vte_sh = configure_file(
+  input: 'vte.sh.in',
+  output: '@BASENAME@',
+  configuration: {
+    'libexecdir': vte_prefix / vte_libexecdir,
+  },
+  install: true,
   install_dir: vte_sysconfdir / 'profile.d',
 )
 
diff --git a/src/vte.sh b/src/vte.sh.in
similarity index 64%
rename from src/vte.sh
rename to src/vte.sh.in
index aff85f82..8b3153da 100644
--- a/src/vte.sh
+++ b/src/vte.sh.in
@@ -1,5 +1,4 @@
-# Copyright © 2006 Shaun McCance <shaunm gnome org>
-# Copyright © 2013 Peter De Wachter <pdewacht gmail com>
+# Copyright © 2012 Christian Persch
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -23,31 +22,16 @@
 # Not running under vte?
 [ "${VTE_VERSION:-0}" -ge 3405 ] || return 0
 
-__vte_urlencode() (
-  # This is important to make sure string manipulation is handled
-  # byte-by-byte.
-  LC_ALL=C
-  str="$1"
-  while [ -n "$str" ]; do
-    safe="${str%%[!a-zA-Z0-9/:_\.\-\!\'\(\)~]*}"
-    printf "%s" "$safe"
-    str="${str#"$safe"}"
-    if [ -n "$str" ]; then
-      printf "%%%02X" "'$str"
-      str="${str#?}"
-    fi
-  done
-)
-
 __vte_osc7 () {
-  printf "\033]7;file://%s%s\033\\" "${HOSTNAME:-}" "$(__vte_urlencode "${PWD}")"
+  printf "\033]7;file://%s%s\033\\" "${HOSTNAME}" "$(@libexecdir@/vte-urlencode-cwd)"
 }
 
 __vte_prompt_command() {
   local pwd='~'
   [ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/}
   pwd="${pwd//[[:cntrl:]]}"
-  printf "\033]0;%s@%s:%s\033\\%s" "${USER}" "${HOSTNAME%%.*}" "${pwd}" "$(__vte_osc7)"
+  printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${pwd}"
+  __vte_osc7
 }
 
 case "$TERM" in


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]