Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Possible issue with Completion/Unix/Type/_date_formats return value



Sure,

Patch is attached and here:
diff --git a/Completion/Unix/Type/_date_formats b/Completion/Unix/Type/_date_formats
index 889a9577..226e1ef7 100644
--- a/Completion/Unix/Type/_date_formats
+++ b/Completion/Unix/Type/_date_formats
@@ -1,6 +1,6 @@
 #autoload
 
-local flag
+local flag ret=1
 local -aU specs
 local -A exclusion
 
@@ -106,5 +106,6 @@ for flag in ${(s..)PREFIX#%}; do
 done
 
 _describe -t date-format-specifier 'date format specifier' specs \
-    -p "${(Q)PREFIX:-%}" -S ''
+    -p "${(Q)PREFIX:-%}" -S '' && ret=0
 [[ $1 == zsh ]] && _message -e date-format-precision 'precision for %%. (1-9)'
+return ret

On Tue, 26 Jan 2021 at 18:37, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
Jacob Menke wrote on Wed, Jan 20, 2021 at 17:43:31 -0500:
> Hello,
>
> I was wondering if _date_formats has an improper return value.
>
> When called from _date (when $1 is unset, thus $1 == zsh is
> false) _date_formats always returns 1 even when matches are generated from
> _describe.  This causes completion to continue erroneously.
>
> Last two lines are shown:
> _describe -t date-format-specifier 'date format specifier' specs
>     -p "${(Q)PREFIX:-%}" -S ''
> [[ $1 == zsh ]] && _message -e date-format-precision 'precision for %%.(1-9)'
>
> I believe the return value of _describe should be returned either by making
> _describe last statement or storing its value in local var ret and then
> returning ret.

Thanks for the report and sorry for the late answer.  I agree that it's wrong
as it stands.  Anyone wants to take it from here?

Attachment: _date_format-ret.patch
Description: Binary data



Messages sorted by: Reverse Date, Date, Thread, Author