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

Re: [completion] GDB completion bug



On 22 Nov, Arusekk wrote:
> The bug is not critical in any way, but just happens in the following 
> setting:
>
> zsh-5.8% gdb (cursor here) -h

> _pids:shift:13: shift count must be <= $#
> _pids:compadd:42: bad option: -m

In this case, I think we can fix this by limiting the search of the
$words array to words preceding the cursor as in the following patch.
I've also updated somewhat the pattern for options that might take
an argument in a following word.

In general, gdb completion could be improved quite a bit more.

> Glad to have found a bug in such reliable software!
> Arusekk

Thanks for reporting this and sorry for not dealing with it sooner.

Oliver

diff --git a/Completion/Unix/Command/_gdb b/Completion/Unix/Command/_gdb
index 18f797633..6bdd55946 100644
--- a/Completion/Unix/Command/_gdb
+++ b/Completion/Unix/Command/_gdb
@@ -40,9 +40,9 @@ else
   (-b)     _baudrates && return 0 ;;
   esac
 
-  w=( "${(@)words[2,-1]}" )
+  w=( "${(@)words[2,CURRENT-1]}" )
   while [[ "$w[1]" = -* ]]; do
-    [[ "$w[1]" = -[decsxb] ]] && shift 1 w
+    [[ "$w[1]" = -(cd|se|tty|[decsxb]) ]] && shift 1 w
     shift 1 w
   done
 




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