Bash-4.3 distribution sources and documentation
[platform/upstream/bash.git] / builtins / shopt.def
index 6cd8c4f..6050a14 100644 (file)
@@ -1,7 +1,7 @@
 This file is shopt.def, from which is created shopt.c.
 It implements the Bash `shopt' builtin.
 
-Copyright (C) 1994-2010 Free Software Foundation, Inc.
+Copyright (C) 1994-2012 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -88,6 +88,7 @@ extern int gnu_error_format;
 extern int check_jobs_at_exit;
 extern int autocd;
 extern int glob_star;
+extern int glob_asciirange;
 extern int lastpipe_opt;
 
 #if defined (EXTENDED_GLOB)
@@ -99,6 +100,7 @@ extern int hist_verify, history_reediting, perform_hostname_completion;
 extern int no_empty_command_completion;
 extern int force_fignore;
 extern int dircomplete_spelling, dircomplete_expand;
+extern int complete_fullquote;
 
 extern int enable_hostname_completion __P((int));
 #endif
@@ -134,6 +136,7 @@ static int shopt_compat31;
 static int shopt_compat32;
 static int shopt_compat40;
 static int shopt_compat41;
+static int shopt_compat42;
 
 typedef int shopt_set_func_t __P((char *, int));
 
@@ -157,7 +160,9 @@ static struct {
   { "compat32", &shopt_compat32, set_compatibility_level },
   { "compat40", &shopt_compat40, set_compatibility_level },
   { "compat41", &shopt_compat41, set_compatibility_level },
+  { "compat42", &shopt_compat41, set_compatibility_level },
 #if defined (READLINE)
+  { "complete_fullquote", &complete_fullquote, (shopt_set_func_t *)NULL},
   { "direxpand", &dircomplete_expand, shopt_set_complete_direxpand },
   { "dirspell", &dircomplete_spelling, (shopt_set_func_t *)NULL },
 #endif
@@ -176,6 +181,7 @@ static struct {
   { "force_fignore", &force_fignore, (shopt_set_func_t *)NULL },
 #endif
   { "globstar", &glob_star, (shopt_set_func_t *)NULL },
+  { "globasciiranges", &glob_asciirange, (shopt_set_func_t *)NULL },
   { "gnu_errfmt", &gnu_error_format, (shopt_set_func_t *)NULL },
 #if defined (HISTORY)
   { "histappend", &force_append_history, (shopt_set_func_t *)NULL },
@@ -298,10 +304,12 @@ reset_shopt_options ()
   allow_null_glob_expansion = glob_dot_filenames = 0;
   cdable_vars = mail_warning = 0;
   no_exit_on_failed_exec = print_shift_error = 0;
-  check_hashed_filenames = cdspelling = expand_aliases = check_window_size = 0;
+  check_hashed_filenames = cdspelling = expand_aliases = 0;
 
   source_uses_path = promptvars = 1;
 
+  check_window_size = CHECKWINSIZE_DEFAULT;
+
 #if defined (EXTENDED_GLOB)
   extended_glob = 0;
 #endif
@@ -521,16 +529,18 @@ set_compatibility_level (option_name, mode)
      char *option_name;
      int mode;
 {
-  /* Need to change logic here as we add more compatibility levels */
+  int ind;
 
-  /* First, check option_name so we can turn off other compat options when
-     one is set. */
-  if (mode && option_name[6] == '3' && option_name[7] == '1')
-    shopt_compat32 = shopt_compat40 = 0;
-  else if (mode && option_name[6] == '3' && option_name[7] == '2')
-    shopt_compat31 = shopt_compat40 = 0;
-  else if (mode && option_name[6] == '4' && option_name[7] == '0')
-    shopt_compat31 = shopt_compat32 = 0;
+  /* If we're setting something, redo some of the work we did above in
+     toggle_shopt().  Unset everything and reset the appropriate option
+     based on OPTION_NAME. */
+  if (mode)
+    {
+      shopt_compat31 = shopt_compat32 = 0;
+      shopt_compat40 = shopt_compat41 = shopt_compat42 = 0;
+      ind = find_shopt (option_name);
+      *shopt_vars[ind].value = mode;
+    }
 
   /* Then set shell_compatibility_level based on what remains */
   if (shopt_compat31)
@@ -539,11 +549,39 @@ set_compatibility_level (option_name, mode)
     shell_compatibility_level = 32;
   else if (shopt_compat40)
     shell_compatibility_level = 40;
+  else if (shopt_compat41)
+    shell_compatibility_level = 41;
+  else if (shopt_compat42)
+    shell_compatibility_level = 42;
   else
     shell_compatibility_level = DEFAULT_COMPAT_LEVEL;
+
   return 0;
 }
 
+/* Set and unset the various compatibility options from the value of
+   shell_compatibility_level; used by sv_shcompat */
+void
+set_compatibility_opts ()
+{
+  shopt_compat31 = shopt_compat32 = shopt_compat40 = shopt_compat41 = shopt_compat42 = 0;
+  switch (shell_compatibility_level)
+    {
+      case DEFAULT_COMPAT_LEVEL:
+       break;
+      case 42:
+       shopt_compat42 = 1; break;
+      case 41:
+       shopt_compat41 = 1; break;
+      case 40:
+       shopt_compat40 = 1; break;
+      case 32:
+       shopt_compat32 = 1; break;
+      case 31:
+       shopt_compat31 = 1; break;
+    }
+}
+
 #if defined (READLINE)
 static int
 shopt_set_complete_direxpand (option_name, mode)