[vte/wip/issue-206: 3/4] vte.sh: Use the vte-urlencode utility
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/wip/issue-206: 3/4] vte.sh: Use the vte-urlencode utility
- Date: Mon, 20 Jan 2020 20:16:01 +0000 (UTC)
commit 66d3f29ab31aa1b4ff69ba1424a09ef9fa5437d3
Author: Carlos Santos <casantos redhat com>
Date: Mon Jan 20 21:13:24 2020 +0100
vte.sh: Use the vte-urlencode utility
Drop the __vte_urlencode function and use the vte-urlencode 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.
Use generate_vte_sh.sh to process vte.sh.in, using libexecdir to set the
full path of vte-urlencode, and write vte.sh.
Drop the __vte_urlencode test, since the function does not exist anymore
and vte-urlencode has its own test.
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 d1220e55..7894549a 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..db32988b 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)"
}
__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]