summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Isidoro <denisidoro@users.noreply.github.com>2020-01-20 16:44:21 -0300
committerGitHub <noreply@github.com>2020-01-20 16:44:21 -0300
commite9dc75555b4bf5287f77209670994a0ac693840c (patch)
treeed743640ac422733d3f4d4136fb7e200d9d71083
parenta70c6dfadd2a82f65a5569f06de98a4fd5fa6374 (diff)
Correctly escape backslashes (#177)v0.18.1
Fixes #131
-rwxr-xr-xnavi2
-rw-r--r--src/arg.sh2
-rw-r--r--[-rwxr-xr-x]src/cheat.sh0
-rw-r--r--src/cmd.sh6
-rw-r--r--src/selection.sh4
-rw-r--r--src/str.sh3
-rw-r--r--src/ui.sh2
7 files changed, 11 insertions, 8 deletions
diff --git a/navi b/navi
index 16da67f..a3face8 100755
--- a/navi
+++ b/navi
@@ -4,7 +4,7 @@ set -euo pipefail
export NAVI_HOME="$(cd "$(dirname "$0")" && pwd)"
source "${NAVI_HOME}/src/main.sh"
-VERSION="0.18.0"
+VERSION="0.18.1"
NAVI_ENV="${NAVI_ENV:-prod}"
opts::eval "$@"
diff --git a/src/arg.sh b/src/arg.sh
index 6fd2afc..0897673 100644
--- a/src/arg.sh
+++ b/src/arg.sh
@@ -67,6 +67,8 @@ arg::serialize_code() {
printf "tr \"'\" '${ESCAPE_CHAR_2}'"
printf " | "
printf "tr '\"' '${ESCAPE_CHAR_3}'"
+ printf " | "
+ printf "tr '\\\\' '${ESCAPE_CHAR_4}'"
}
arg::pick() {
diff --git a/src/cheat.sh b/src/cheat.sh
index 84bf6ea..84bf6ea 100755..100644
--- a/src/cheat.sh
+++ b/src/cheat.sh
diff --git a/src/cmd.sh b/src/cmd.sh
index f0bdd8e..f52e48f 100644
--- a/src/cmd.sh
+++ b/src/cmd.sh
@@ -1,11 +1,11 @@
#!/usr/bin/env bash
cmd::escape() {
- tr '\\' "$ESCAPE_CHAR_3"
+ tr '\\' "$ESCAPE_CHAR_4"
}
cmd::unescape() {
- tr "$ESCAPE_CHAR_3" '\\'
+ tr "$ESCAPE_CHAR_4" '\\'
}
cmd::loop() {
@@ -50,4 +50,4 @@ cmd::finish() {
else
eval "$cmd"
fi
-} \ No newline at end of file
+}
diff --git a/src/selection.sh b/src/selection.sh
index 06cde84..c39b742 100644
--- a/src/selection.sh
+++ b/src/selection.sh
@@ -15,7 +15,7 @@ selection_str::comment() {
}
selection_str::snippet() {
- echo "$*" | awk -F "${SELECTION_ESCAPE_STR}" '{print $2}' | selection_str::without_ellipsis
+ echo "$*" | awk -F "${SELECTION_ESCAPE_STR}" '{print $2}' | selection_str::without_ellipsis | cmd::escape
}
selection_str::tags() {
@@ -72,4 +72,4 @@ selection::tags() {
selection::key() {
local -r selection="$1"
dict::get "$selection" key
-} \ No newline at end of file
+}
diff --git a/src/str.sh b/src/str.sh
index 55ed101..0f26489 100644
--- a/src/str.sh
+++ b/src/str.sh
@@ -3,6 +3,7 @@
ESCAPE_CHAR="\034"
ESCAPE_CHAR_2="\035"
ESCAPE_CHAR_3="\036"
+ESCAPE_CHAR_4="\037"
str::length() {
awk '{print length}'
@@ -82,4 +83,4 @@ str::as_column() {
str::with_line_numbers() {
awk '{printf("%d %s\n", NR,$0)}'
-} \ No newline at end of file
+}
diff --git a/src/ui.sh b/src/ui.sh
index 6716c75..1395383 100644
--- a/src/ui.sh
+++ b/src/ui.sh
@@ -23,7 +23,7 @@ ui::select() {
[[ "${SHELL:-}" =~ 'fish' ]] || local -r sub='$'
local -r script_path="${NAVI_HOME}/navi"
- local -r preview_cmd="\"${script_path}\" preview ${sub:-}(echo \'{}\' | $(arg::serialize_code))"
+ local -r preview_cmd="\"${script_path}\" preview ${sub:-}(echo \'{}\' | $(arg::serialize_code) 2> /dev/null)"
local -r query="$(dict::get "$OPTIONS" query)"
local -r entry_point="$(dict::get "$OPTIONS" entry_point)"