From 32484373263aecabb705950079e40d93ddfbbf75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Koutn=C3=BD?= Date: Tue, 25 Jul 2023 21:29:50 +0200 Subject: [PATCH] Fix fish completion (#3068) * Fix fish completions As per [1] printf in fish does not support '--' as a delimiter of format string and args. It used to work (accidentally) earlier (fish 3.5, glibc 2.31) but it is broken (fish 3.6, glibc 2.36) nowadays. Fix it by using the simple form of printf invocation with no argument escaping. Fixes: #3048 [1] https://fishshell.com/docs/current/cmds/printf.html#description * Fix fish completions with older fish Older versions (fish 3.5) cannot cope with '-' in printf format hence add a workaround for these. --- scripts/fish/task.fish | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/scripts/fish/task.fish b/scripts/fish/task.fish index 741dfbcf6..f3cb62e1d 100644 --- a/scripts/fish/task.fish +++ b/scripts/fish/task.fish @@ -295,8 +295,9 @@ end function __fish.task.list.tag set -l tags (task _tags) - printf -- '+%s\n' $tags - printf -- '-%s\n' $tags + printf '+%s\n' $tags + # compatibility, older fish won't allow - in format + printf ' %s\n' $tags | tr ' ' '-' end function __fish.task.list.task @@ -354,10 +355,10 @@ end # static variables that won't changes even when taskw's data is modified set __fish_task_static_commands_with_desc (__fish.task.zsh commands | sort | string collect) set __fish_task_static_commands (echo -e $__fish_task_static_commands_with_desc | cut -d ' ' -f 1 | string collect) -set __fish_task_static_command_mods (printf -- '%s\n' 'add' 'annotate' 'append' 'delete' 'done' 'duplicate' 'log' 'modify' 'prepend' 'start' 'stop' | string collect) -set __fish_task_static_mod (printf -- '%s\n' 'before' 'after' 'over' 'under' 'none' 'is' 'isnt' 'has' 'hasnt' 'startswith' 'endswith' 'word' 'noword' | string collect) -set __fish_task_static_status (printf -- '%s\tstatus\n' 'pending' 'completed' 'deleted' 'waiting' | string collect) -set __fish_task_static_priority (printf -- '%s\n' 'H\tHigh' 'M\tMiddle' 'L\tLow' | string collect) +set __fish_task_static_command_mods (printf '%s\n' 'add' 'annotate' 'append' 'delete' 'done' 'duplicate' 'log' 'modify' 'prepend' 'start' 'stop' | string collect) +set __fish_task_static_mod (printf '%s\n' 'before' 'after' 'over' 'under' 'none' 'is' 'isnt' 'has' 'hasnt' 'startswith' 'endswith' 'word' 'noword' | string collect) +set __fish_task_static_status (printf '%s\tstatus\n' 'pending' 'completed' 'deleted' 'waiting' | string collect) +set __fish_task_static_priority (printf '%s\n' 'H\tHigh' 'M\tMiddle' 'L\tLow' | string collect) set __fish_task_static_freq 'daily:Every day' \ 'day:Every day' \ @@ -372,17 +373,17 @@ set __fish_task_static_freq 'daily:Every day' \ 'yearly:Every year' \ 'biannual:Every two years' \ 'biyearly:Every two years' -set __fish_task_static_freq (printf -- '%s\n' $__fish_task_static_freq | sed 's/:/\t/' | string collect) +set __fish_task_static_freq (printf '%s\n' $__fish_task_static_freq | sed 's/:/\t/' | string collect) set __fish_task_static_freq_numeric 'd:days' \ 'w:weeks' \ 'q:quarters' \ 'y:years' -set __fish_task_static_freq_numeric (printf -- '%s\n' $__fish_task_static_freq_numeric | sed 's/:/\t/' | string collect) +set __fish_task_static_freq_numeric (printf '%s\n' $__fish_task_static_freq_numeric | sed 's/:/\t/' | string collect) set __fish_task_static_freq_numeric 'd:days' \ 'w:weeks' \ 'q:quarters' \ 'y:years' -set __fish_task_static_freq_numeric (printf -- '%s\n' $__fish_task_static_freq_numeric | sed 's/:/\t/' | string collect) +set __fish_task_static_freq_numeric (printf '%s\n' $__fish_task_static_freq_numeric | sed 's/:/\t/' | string collect) set __fish_task_static_dates 'today:Today' \ 'yesterday:Yesterday' \ 'tomorrow:Tomorrow' \ @@ -414,7 +415,7 @@ set __fish_task_static_dates 'today:Today' \ 'midsommarafton:Midsommarafton' \ 'later:Later' \ 'someday:Some Day' -set __fish_task_static_dates (printf -- '%s\n' $__fish_task_static_dates | sed 's/:/\t/' | string collect) +set __fish_task_static_dates (printf '%s\n' $__fish_task_static_dates | sed 's/:/\t/' | string collect) set __fish_task_static_reldates 'hrs:n hours' \ 'day:n days' \ # '1st:first' \ @@ -422,7 +423,7 @@ set __fish_task_static_reldates 'hrs:n hours' \ # '3rd:third' \ # 'th:4th, 5th, etc.' \ 'wks:weeks' -set __fish_task_static_reldates (printf -- '%s\n' $__fish_task_static_reldates | sed 's/:/\t/' | string collect) +set __fish_task_static_reldates (printf '%s\n' $__fish_task_static_reldates | sed 's/:/\t/' | string collect) # the followings are actually not used for autocomplete, but to retrieve friendly description that aren't present in internal command set __fish_task_static_attr_desc_keys 'description' 'status' 'project' \ 'priority' 'due' 'recur' \