From c8da07f3ed36af3a3eb5371c417be6376537a8f4 Mon Sep 17 00:00:00 2001 From: Alex Pasmantier <47638216+alexpasmantier@users.noreply.github.com> Date: Sat, 19 Jul 2025 23:05:31 +0200 Subject: [PATCH] fix(fish): more robust string escaping (#656) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #653 > https://github.com/alexpasmantier/television/blob/28f58e0641e3e4a56f02c39e165642024da430df/television/utils/shell/completion.fish#L112 > > This line should be > > ``` > commandline -t -- (string escape -- "$dir$i")' ' > ``` > > This is a bug in the fish completion. Bash seems to be fine. > > Testing with: > > ``` > ❯ fish --version > fish, version 4.0.2 > > ❯ mkdir -p "a/with whitespace" > > ❯ cd a > ``` > > Result: > > ``` > ❯ cd a/'with whitespace/' > ``` > > Expected result: > > ``` > ❯ cd 'a/with whitespace/' > ``` > > The fix on top gets this result. --- television/utils/shell/completion.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/television/utils/shell/completion.fish b/television/utils/shell/completion.fish index 95ba5b8..e9dbf22 100644 --- a/television/utils/shell/completion.fish +++ b/television/utils/shell/completion.fish @@ -109,9 +109,9 @@ function tv_smart_autocomplete end for i in $result - commandline -it -- $dir(string escape -- $i)' ' + commandline -t -- (string escape -- "$dir$i")' ' # optional, if you want to replace '/home/foo/' with '~/', comment out above and uncomment below - # commandline -it -- (string replace --all $HOME '~' $dir(string escape -- $i))' ' + # commandline -t -- (string replace --all $HOME '~' -- (string escape -- "$dir$i"))' ' end end