Skip to content

Commit

Permalink
Fix fish completion by escaping characters
Browse files Browse the repository at this point in the history
Escape every tldr page name to prevent fish syntax errors.

This fixes the problem in which special characters in fish were not
escaped when fish shell completion was added in tldr-pages#17, because at the time
none of the pages in <https://github.com/tldr-pages/tldr> had names that
were syntactically special in fish. This meant that escaping was
unnecessary.

However, as a result of <tldr-pages/tldr#7530>,
which added the files `[.md` and `[[.md`, the fish shell autocompletion
will now cause a syntax error in fish whenever autocompletion triggers.

This syntax error fills stderr with long error messages and prevents the
fish autocompletion from running. This problem is fixed by escaping
characters like `[`, which is done in this commit.

See also: <tldr-pages/tldr#7530>, tldr-pages#17
  • Loading branch information
superatomic committed May 1, 2022
1 parent be56821 commit 45cd3d5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Deprecated features will be kept for any following maintenance release, and
will be removed after two major releases.

## [Unreleased]
### Fixed
- Fix fish completion not escaping characters

## v1.4.3 - 2022-04-11
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion autocomplete/complete.fish
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ complete -c tldr -r -s r -l render -a PATH -d "render a local page for testing p
function __tldr_get_files
set -l files (basename -s .md (find $HOME/.tldrc/tldr/pages/$argv[1] -name '*.md'))
for f in $files
echo $f
echo $f | string escape
end
end

Expand Down

0 comments on commit 45cd3d5

Please sign in to comment.