Skip to content

Commit

Permalink
Merge pull request #145 from d3dave/fish-fixes
Browse files Browse the repository at this point in the history
- Fix literal \n in history entries in Fish
- Parent traversal via .. doesn't work because filepath_abs doesn't 
properly trim the newline character. After the new line, that is still
there, gets translated by Fish to a space (via IFS), it results in the 
dir variable having an extra trailing space. The resulting string 
isn't a real path, so the awk script fails.
  • Loading branch information
jorgebucaran authored Jan 4, 2021
2 parents 449cdb2 + 9ab8396 commit 8920a3d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
9 changes: 5 additions & 4 deletions functions/_enhancd_cd_after.fish
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
function _enhancd_cd_after
set -l list
set list (_enhancd_history_update)
# Don't split on newlines throughout this function:
set -l IFS ""

set -l list (_enhancd_history_update)

if test -n "$list"
# Workaround to print one folder per line
string replace -a ' ' '\n' $list >"$ENHANCD_DIR/enhancd.log"
echo "$list" >"$ENHANCD_DIR/enhancd.log"
end

if test -n "$ENHANCD_HOOK_AFTER_CD"
Expand Down
2 changes: 1 addition & 1 deletion functions/_enhancd_filepath_abs.fish
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function _enhancd_filepath_abs
if test -z "$dir"; or test -p /dev/stdin
read -z dir
# trim newline for awk scripts to works correctly
set dir (string trim -c '\n' "$dir")
set dir (string trim -c \n "$dir")
end

if test -z "$dir"
Expand Down
6 changes: 5 additions & 1 deletion functions/_enhancd_source_default.fish
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ function _enhancd_source_default
echo "$HOME"
return 0
end
string split '\n' (_enhancd_entry_git_root) (_enhancd_history_list) | _enhancd_filter_interactive

begin
_enhancd_entry_git_root
_enhancd_history_list
end | _enhancd_filter_interactive
end

0 comments on commit 8920a3d

Please sign in to comment.