diff --git a/autotools/build-bash-completion b/autotools/build-bash-completion
index 365dad98a4a4dad65f03e8b51f16caa57d436523..0cae30158ea695312113e4d2f7d79aabfcc2d2ed 100755
--- a/autotools/build-bash-completion
+++ b/autotools/build-bash-completion
@@ -622,6 +622,11 @@ def main():
   buf = StringIO()
   sw = utils.ShellWriter(buf)
 
+  # Remember original state of extglob and enable it (required for pattern
+  # matching; must be enabled while parsing script)
+  sw.Write("gnt_shopt_extglob=$(shopt -p extglob || :)")
+  sw.Write("shopt -s extglob")
+
   WritePreamble(sw)
 
   # gnt-* scripts
@@ -638,6 +643,10 @@ def main():
   WriteCompletion(sw, "%s/burnin" % constants.TOOLSDIR, "_ganeti_burnin",
                   opts=burnin.OPTIONS, args=burnin.ARGUMENTS)
 
+  # Reset extglob to original value
+  sw.Write("[[ -n \"$gnt_shopt_extglob\" ]] && $gnt_shopt_extglob")
+  sw.Write("unset gnt_shopt_extglob")
+
   print buf.getvalue()