From dbcd7eae4a7bb175d5831d4846d8781d05eaa5dd Mon Sep 17 00:00:00 2001 From: Denis Isidoro Date: Wed, 22 Jan 2020 17:26:25 -0300 Subject: [PATCH] Revert "Correctly escape backslashes" (#181) Reverts #177 Fixes #179 but reopens #131 --- navi | 2 +- src/arg.sh | 2 -- src/cheat.sh | 0 src/cmd.sh | 6 +++--- src/selection.sh | 4 ++-- src/str.sh | 3 +-- src/ui.sh | 2 +- 7 files changed, 8 insertions(+), 11 deletions(-) mode change 100644 => 100755 src/cheat.sh diff --git a/navi b/navi index a3face81..ab5a3466 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.1" +VERSION="0.18.2" NAVI_ENV="${NAVI_ENV:-prod}" opts::eval "$@" diff --git a/src/arg.sh b/src/arg.sh index 08976735..6fd2afc1 100644 --- a/src/arg.sh +++ b/src/arg.sh @@ -67,8 +67,6 @@ 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 old mode 100644 new mode 100755 diff --git a/src/cmd.sh b/src/cmd.sh index f52e48fa..f0bdd8ea 100644 --- a/src/cmd.sh +++ b/src/cmd.sh @@ -1,11 +1,11 @@ #!/usr/bin/env bash cmd::escape() { - tr '\\' "$ESCAPE_CHAR_4" + tr '\\' "$ESCAPE_CHAR_3" } cmd::unescape() { - tr "$ESCAPE_CHAR_4" '\\' + tr "$ESCAPE_CHAR_3" '\\' } 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 c39b742f..06cde84f 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 | cmd::escape + echo "$*" | awk -F "${SELECTION_ESCAPE_STR}" '{print $2}' | selection_str::without_ellipsis } 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 0f264899..55ed1014 100644 --- a/src/str.sh +++ b/src/str.sh @@ -3,7 +3,6 @@ ESCAPE_CHAR="\034" ESCAPE_CHAR_2="\035" ESCAPE_CHAR_3="\036" -ESCAPE_CHAR_4="\037" str::length() { awk '{print length}' @@ -83,4 +82,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 1395383b..6716c759 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) 2> /dev/null)" + local -r preview_cmd="\"${script_path}\" preview ${sub:-}(echo \'{}\' | $(arg::serialize_code))" local -r query="$(dict::get "$OPTIONS" query)" local -r entry_point="$(dict::get "$OPTIONS" entry_point)"