bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Different COMP_WORDS array values with exactly the same commandline


From: werner
Subject: Different COMP_WORDS array values with exactly the same commandline
Date: Fri, 30 Jan 2009 18:01:06 +0100

Configuration Information [Automatically generated, do not change]:
Machine: i586
OS: linux-gnu
Compiler: gcc -I/usr/src/packages/BUILD/bash-3.2 
-L/usr/src/packages/BUILD/bash-3.2/../readline-5.2
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i586' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i586-suse-linux-gnu' 
-DCONF_VENDOR='suse' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib   -O2 -march=i586 -mtune=i686 
-fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables 
-fasynchronous-unwind-tables -g -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 
-D_GNU_SOURCE -DRECYCLES_PIDS -Wall -g -std=gnu89 -Wextra 
-Wno-unprototyped-calls -Wno-switch-enum -pipe
uname output: Linux boole 2.6.27.7-9-pae #1 SMP 2008-12-04 18:10:04 +0100 i686 
i686 i386 GNU/Linux
Machine Type: i586-suse-linux-gnu

Bash Version: 3.2
Patch Level: 48
Release Status: release

Description:
Different address@hidden values with exactly the same commandline
due not restored state of complete variables.

Repeat-By:
i)   Use a shell function for complete a command like here
     # yast2 ftp-<TAB>
ii)  If you have seen the error then you are finished; if not, hit several
     times <TAB> (even though the command line now looks like "yast2 
tftp-server")
     and then <CTRL>+C
iii) Type yast2 ftp-<TAB> again and you should see the error:

     # yast2 ftp--bash: COMP_WORDS: bad array subscript
     server

for reference see https://bugzilla.novell.com/show_bug.cgi?id=470548
should visible with all command completions using a shell function
which uses COMP_WORDS and if on the comamnd line a word with `-'
is used.

Fix:
--- pcomplete.c
+++ pcomplete.c 2009-01-30 16:59:12.648484782 +0100
@@ -990,7 +990,7 @@ gen_shell_function_matches (cs, text, li
   SHELL_VAR *f, *v;
   WORD_LIST *cmdlist;
   int fval;
-  sh_parser_state_t ps;
+  sh_parser_state_t ps, *__restrict__ pps = &ps;
 #if defined (ARRAY_VARS)
   ARRAY *a;
 #endif
@@ -1015,9 +1015,16 @@ gen_shell_function_matches (cs, text, li
 
   cmdlist = build_arg_list (funcname, text, lwords, cw);
 
-  save_parser_state (&ps);  
-  fval = execute_shell_function (f, cmdlist);  
-  restore_parser_state (&ps);
+  save_parser_state (pps);
+  begin_unwind_frame ("gen-shell-function-matches");
+  add_unwind_protect (restore_parser_state, (char *)pps);
+  add_unwind_protect (dispose_words, (char *)cmdlist);
+  add_unwind_protect (unbind_compfunc_variables, (char *)0);
+
+  fval = execute_shell_function (f, cmdlist);
+
+  discard_unwind_frame ("gen-shell-function-matches");
+  restore_parser_state (pps);
 
   /* Now clean up and destroy everything. */
   dispose_words (cmdlist);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]