diff --git a/share/functions/__fish_complete_list.fish b/share/functions/__fish_complete_list.fish index 758489572..b2e5c88f3 100644 --- a/share/functions/__fish_complete_list.fish +++ b/share/functions/__fish_complete_list.fish @@ -19,12 +19,12 @@ where: end switch $pat case "*$div*" - for i in (echo $pat | sed "s/^\(.\+$div\)$iprefix.*\$/\1/")$iprefix(eval $cmd) - string unescape -- $i + for i in (string unescape -- $pat | sed "s/^\(.\+$div\)$iprefix.*\$/\1/")$iprefix(eval $cmd) + printf %s\n $i end case '*' for i in $prefix$iprefix(eval $cmd) - string unescape -- $i + printf %s\n $i end end diff --git a/tests/checks/complete.fish b/tests/checks/complete.fish index 739d675e6..f90b98aab 100644 --- a/tests/checks/complete.fish +++ b/tests/checks/complete.fish @@ -647,3 +647,10 @@ complete -C "complete-list --number-list=1," complete -C "complete-list -abcl1," # CHECK: -abcl1,1 # CHECK: -abcl1,2 + +function esc_in_description + echo completion\t'escaped \n newline' +end +complete complete-list -l desc -xa '(__fish_complete_list , esc_in_description)' +complete -C 'complete-list --desc ' +# CHECK: completion{{\t}}escaped {{\\n}} newline