Skip to content

Commit

Permalink
Revert "Correctly escape backslashes" (#181)
Browse files Browse the repository at this point in the history
Reverts #177

Fixes #179 but reopens #131
  • Loading branch information
denisidoro authored Jan 22, 2020
1 parent 4d7b58f commit dbcd7ea
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion navi
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$@"
Expand Down
2 changes: 0 additions & 2 deletions src/arg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Empty file modified src/cheat.sh
100644 → 100755
Empty file.
6 changes: 3 additions & 3 deletions src/cmd.sh
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -50,4 +50,4 @@ cmd::finish() {
else
eval "$cmd"
fi
}
}
4 changes: 2 additions & 2 deletions src/selection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -72,4 +72,4 @@ selection::tags() {
selection::key() {
local -r selection="$1"
dict::get "$selection" key
}
}
3 changes: 1 addition & 2 deletions src/str.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
ESCAPE_CHAR="\034"
ESCAPE_CHAR_2="\035"
ESCAPE_CHAR_3="\036"
ESCAPE_CHAR_4="\037"

str::length() {
awk '{print length}'
Expand Down Expand Up @@ -83,4 +82,4 @@ str::as_column() {

str::with_line_numbers() {
awk '{printf("%d %s\n", NR,$0)}'
}
}
2 changes: 1 addition & 1 deletion src/ui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down

0 comments on commit dbcd7ea

Please sign in to comment.