Revert "bash_completion: Always enable extglob"
authorMichael Hanselmann <hansmi@google.com>
Mon, 24 Sep 2012 12:43:20 +0000 (14:43 +0200)
committerMichael Hanselmann <hansmi@google.com>
Tue, 25 Sep 2012 11:14:27 +0000 (13:14 +0200)
This reverts commit 94014b6328f813b674a1126ffd221705d7e315b3. Turns out
I misunderstood the “extglob” shell option.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Bernardo Dal Seno <bdalseno@google.com>

autotools/build-bash-completion

index 05ac04f..359f7a8 100755 (executable)
@@ -526,12 +526,13 @@ def WriteCompletion(sw, scriptname, funcname, support_debug,
   @param commands: List of all subcommands in this program
 
   """
-  sw.Write("%s_inner() {", funcname)
+  sw.Write("%s() {", funcname)
   sw.IncIndent()
   try:
-    sw.Write("local i first_arg_idx choices compgenargs arg_idx optcur"
+    sw.Write("local "
              ' cur="${COMP_WORDS[COMP_CWORD]}"'
-             ' prev="${COMP_WORDS[COMP_CWORD-1]}"')
+             ' prev="${COMP_WORDS[COMP_CWORD-1]}"'
+             ' i first_arg_idx choices compgenargs arg_idx optcur')
 
     if support_debug:
       sw.Write("_gnt_log cur=\"$cur\" prev=\"$prev\"")
@@ -581,25 +582,6 @@ def WriteCompletion(sw, scriptname, funcname, support_debug,
     sw.DecIndent()
   sw.Write("}")
 
-  # Wrapper function to always enable extglob (needed for advanced pattern
-  # matching)
-  sw.Write("%s() {", funcname)
-  sw.IncIndent()
-  try:
-    # Get current state of extglob
-    sw.Write("local -r eg=$(shopt -p extglob || :)")
-
-    # Enable extglob
-    sw.Write("shopt -s extglob")
-
-    sw.Write("%s_inner \"$@\"", funcname)
-
-    # Reset extglob to original value
-    sw.Write("[[ -n \"$eg\" ]] && $eg")
-  finally:
-    sw.DecIndent()
-  sw.Write("}")
-
   sw.Write("complete -F %s -o filenames %s",
            utils.ShellQuote(funcname),
            utils.ShellQuote(scriptname))