Bash-4.3 distribution sources and documentation
[platform/upstream/bash.git] / builtins / shopt.def
index 138b88d..6050a14 100644 (file)
@@ -1,38 +1,44 @@
 This file is shopt.def, from which is created shopt.c.
 It implements the Bash `shopt' builtin.
 
-Copyright (C) 1994 Free Software Foundation, Inc.
+Copyright (C) 1994-2012 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
-Bash is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
+Bash is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
 
-Bash is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
+Bash is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License along
-with Bash; see the file COPYING.  If not, write to the Free Software
-Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+You should have received a copy of the GNU General Public License
+along with Bash.  If not, see <http://www.gnu.org/licenses/>.
 
 $PRODUCES shopt.c
 
 $BUILTIN shopt
-$DOCNAME shopt_builtin
 $FUNCTION shopt_builtin
-$SHORT_DOC shopt [-pqsu] [-o long-option] optname [optname...]
-Toggle the values of variables controlling optional behavior.
-The -s flag means to enable (set) each OPTNAME; the -u flag
-unsets each OPTNAME.  The -q flag suppresses output; the exit
-status indicates whether each OPTNAME is set or unset.  The -o
-option restricts the OPTNAMEs to those defined for use with
-`set -o'.  With no options, or with the -p option, a list of all
-settable options is displayed, with an indication of whether or
-not each is set.
+$SHORT_DOC shopt [-pqsu] [-o] [optname ...]
+Set and unset shell options.
+
+Change the setting of each shell option OPTNAME.  Without any option
+arguments, list all shell options with an indication of whether or not each
+is set. 
+
+Options:
+  -o   restrict OPTNAMEs to those defined for use with `set -o'
+  -p   print each shell option with an indication of its status
+  -q   suppress output
+  -s   enable (set) each OPTNAME
+  -u   disable (unset) each OPTNAME
+
+Exit Status:
+Returns success if OPTNAME is enabled; fails if an invalid option is
+given or OPTNAME is disabled.
 $END
 
 #include <config.h>
@@ -46,39 +52,57 @@ $END
 
 #include <stdio.h>
 
+#include "version.h"
+
+#include "../bashintl.h"
+
 #include "../shell.h"
 #include "../flags.h"
 #include "common.h"
 #include "bashgetopt.h"
 
+#if defined (READLINE)
+#  include "../bashline.h"
+#endif
+
+#if defined (HISTORY)
+#  include "../bashhist.h"
+#endif
+
 #define UNSETOPT       0
 #define SETOPT         1
 
 #define OPTFMT         "%-15s\t%s\n"
 
-extern int allow_null_glob_expansion, glob_dot_filenames;
+extern int allow_null_glob_expansion, fail_glob_expansion, glob_dot_filenames;
 extern int cdable_vars, mail_warning, source_uses_path;
 extern int no_exit_on_failed_exec, print_shift_error;
-extern int check_hashed_filenames, promptvars, interactive_comments;
+extern int check_hashed_filenames, promptvars;
 extern int cdspelling, expand_aliases;
+extern int extended_quote;
 extern int check_window_size;
-extern int glob_ignore_case;
+extern int glob_ignore_case, match_ignore_case;
 extern int hup_on_exit;
 extern int xpg_echo;
+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)
 extern int extended_glob;
 #endif
 
-#if defined (HISTORY)
-extern int literal_history, command_oriented_history;
-extern int force_append_history;
-#endif
-
 #if defined (READLINE)
 extern int hist_verify, history_reediting, perform_hostname_completion;
 extern int no_empty_command_completion;
-extern void enable_hostname_completion ();
+extern int force_fignore;
+extern int dircomplete_spelling, dircomplete_expand;
+extern int complete_fullquote;
+
+extern int enable_hostname_completion __P((int));
 #endif
 
 #if defined (PROGRAMMABLE_COMPLETION)
@@ -86,76 +110,129 @@ extern int prog_completion_enabled;
 #endif
 
 #if defined (RESTRICTED_SHELL)
-extern int restricted_shell;
 extern char *shell_name;
 #endif
 
-extern void set_shellopts ();
+#if defined (DEBUGGER)
+extern int debugging_mode;
+#endif
+
+static void shopt_error __P((char *));
 
-static int set_interactive_comments ();
+static int set_shellopts_after_change __P((char *, int));
+static int shopt_enable_hostname_completion __P((char *, int));
+static int set_compatibility_level __P((char *, int));
 
 #if defined (RESTRICTED_SHELL)
-static int set_restricted_shell ();
+static int set_restricted_shell __P((char *, int));
+#endif
+
+#if defined (READLINE)
+static int shopt_set_complete_direxpand __P((char *, int));
 #endif
 
+static int shopt_login_shell;
+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));
+
 static struct {
   char *name;
   int  *value;
-  Function *set_func;
+  shopt_set_func_t *set_func;
 } shopt_vars[] = {
-  { "cdable_vars", &cdable_vars, (Function *)NULL },
-  { "cdspell", &cdspelling, (Function *)NULL },
-  { "checkhash", &check_hashed_filenames, (Function *)NULL },
-  { "checkwinsize", &check_window_size, (Function *)NULL },
+  { "autocd", &autocd, (shopt_set_func_t *)NULL },
+  { "cdable_vars", &cdable_vars, (shopt_set_func_t *)NULL },
+  { "cdspell", &cdspelling, (shopt_set_func_t *)NULL },
+  { "checkhash", &check_hashed_filenames, (shopt_set_func_t *)NULL },
+#if defined (JOB_CONTROL)
+  { "checkjobs", &check_jobs_at_exit, (shopt_set_func_t *)NULL },
+#endif
+  { "checkwinsize", &check_window_size, (shopt_set_func_t *)NULL },
 #if defined (HISTORY)
-  { "cmdhist", &command_oriented_history, (Function *)NULL },
+  { "cmdhist", &command_oriented_history, (shopt_set_func_t *)NULL },
+#endif
+  { "compat31", &shopt_compat31, set_compatibility_level },
+  { "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
+  { "dotglob", &glob_dot_filenames, (shopt_set_func_t *)NULL },
+  { "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL },
+  { "expand_aliases", &expand_aliases, (shopt_set_func_t *)NULL },
+#if defined (DEBUGGER)
+  { "extdebug", &debugging_mode, (shopt_set_func_t *)NULL },
 #endif
-  { "dotglob", &glob_dot_filenames, (Function *)NULL },
-  { "execfail", &no_exit_on_failed_exec, (Function *)NULL },
-  { "expand_aliases", &expand_aliases, (Function *)NULL },
 #if defined (EXTENDED_GLOB)
-  { "extglob", &extended_glob, (Function *)NULL },
+  { "extglob", &extended_glob, (shopt_set_func_t *)NULL },
 #endif
+  { "extquote", &extended_quote, (shopt_set_func_t *)NULL },
+  { "failglob", &fail_glob_expansion, (shopt_set_func_t *)NULL },
 #if defined (READLINE)
-  { "histreedit", &history_reediting, (Function *)NULL },
+  { "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, (Function *)NULL },
+  { "histappend", &force_append_history, (shopt_set_func_t *)NULL },
 #endif
 #if defined (READLINE)
-  { "histverify", &hist_verify, (Function *)NULL },
-  { "hostcomplete", &perform_hostname_completion, (Function *)enable_hostname_completion },
+  { "histreedit", &history_reediting, (shopt_set_func_t *)NULL },
+  { "histverify", &hist_verify, (shopt_set_func_t *)NULL },
+  { "hostcomplete", &perform_hostname_completion, shopt_enable_hostname_completion },
 #endif
-  { "huponexit", &hup_on_exit, (Function *)NULL },
-  { "interactive_comments", &interactive_comments, set_interactive_comments },
+  { "huponexit", &hup_on_exit, (shopt_set_func_t *)NULL },
+  { "interactive_comments", &interactive_comments, set_shellopts_after_change },
+  { "lastpipe", &lastpipe_opt, (shopt_set_func_t *)NULL },
 #if defined (HISTORY)
-  { "lithist", &literal_history, (Function *)NULL },
+  { "lithist", &literal_history, (shopt_set_func_t *)NULL },
 #endif
-  { "mailwarn", &mail_warning, (Function *)NULL },
+  { "login_shell", &shopt_login_shell, set_login_shell },
+  { "mailwarn", &mail_warning, (shopt_set_func_t *)NULL },
 #if defined (READLINE)
-  { "no_empty_cmd_completion", &no_empty_command_completion, (Function *)NULL },
+  { "no_empty_cmd_completion", &no_empty_command_completion, (shopt_set_func_t *)NULL },
 #endif
-  { "nocaseglob", &glob_ignore_case, (Function *)NULL },
-  { "nullglob",        &allow_null_glob_expansion, (Function *)NULL },
+  { "nocaseglob", &glob_ignore_case, (shopt_set_func_t *)NULL },
+  { "nocasematch", &match_ignore_case, (shopt_set_func_t *)NULL },
+  { "nullglob",        &allow_null_glob_expansion, (shopt_set_func_t *)NULL },
 #if defined (PROGRAMMABLE_COMPLETION)
-  { "progcomp", &prog_completion_enabled, (Function *)NULL },
+  { "progcomp", &prog_completion_enabled, (shopt_set_func_t *)NULL },
 #endif
-  { "promptvars", &promptvars, (Function *)NULL },
+  { "promptvars", &promptvars, (shopt_set_func_t *)NULL },
 #if defined (RESTRICTED_SHELL)
   { "restricted_shell", &restricted_shell, set_restricted_shell },
 #endif
-  { "shift_verbose", &print_shift_error, (Function *)NULL },
-  { "sourcepath", &source_uses_path, (Function *)NULL },
-  { "xpg_echo", &xpg_echo, (Function *)NULL },
-  { (char *)0, (int *)0, (Function *)NULL }
+  { "shift_verbose", &print_shift_error, (shopt_set_func_t *)NULL },
+  { "sourcepath", &source_uses_path, (shopt_set_func_t *)NULL },
+  { "xpg_echo", &xpg_echo, (shopt_set_func_t *)NULL },
+  { (char *)0, (int *)0, (shopt_set_func_t *)NULL }
 };
 
-static char *on = "on";
-static char *off = "off";
+#define N_SHOPT_OPTIONS                (sizeof (shopt_vars) / sizeof (shopt_vars[0]))
+
+#define GET_SHOPT_OPTION_VALUE(i)      (*shopt_vars[i].value)
 
-static int list_shopt_o_options ();
-static int list_some_o_options (), list_some_shopts ();
-static int toggle_shopts (), list_shopts (), set_shopt_o_options ();
+static const char * const on = "on";
+static const char * const off = "off";
+
+static int find_shopt __P((char *));
+static int toggle_shopts __P((int, WORD_LIST *, int));
+static void print_shopt __P((char *, int, int));
+static int list_shopts __P((WORD_LIST *, int));
+static int list_some_shopts __P((int, int));
+static int list_shopt_o_options __P((WORD_LIST *, int));
+static int list_some_o_options __P((int, int));
+static int set_shopt_o_options __P((int, WORD_LIST *, int));
 
 #define SFLAG  0x01
 #define UFLAG  0x02
@@ -199,7 +276,7 @@ shopt_builtin (list)
 
   if ((flags & (SFLAG|UFLAG)) == (SFLAG|UFLAG))
     {
-      builtin_error ("cannot set and unset shell options simultaneously");
+      builtin_error (_("cannot set and unset shell options simultaneously"));
       return (EXECUTION_FAILURE);
     }
 
@@ -227,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
@@ -244,6 +323,8 @@ reset_shopt_options ()
   hist_verify = history_reediting = 0;
   perform_hostname_completion = 1;
 #endif
+
+  shopt_login_shell = login_shell;
 }
 
 static int
@@ -258,7 +339,12 @@ find_shopt (name)
   return -1;
 }
 
-#define SHOPT_ERROR(str)       builtin_error ("%s: unknown shell option name", str)
+static void
+shopt_error (s)
+     char *s;
+{
+  builtin_error (_("%s: invalid shell option name"), s);
+}
 
 static int
 toggle_shopts (mode, list, quiet)
@@ -274,16 +360,18 @@ toggle_shopts (mode, list, quiet)
       ind = find_shopt (l->word->word);
       if (ind < 0)
        {
-         SHOPT_ERROR (l->word->word);
+         shopt_error (l->word->word);
          rval = EXECUTION_FAILURE;
        }
       else
        {
          *shopt_vars[ind].value = mode;        /* 1 for set, 0 for unset */
          if (shopt_vars[ind].set_func)
-           (*shopt_vars[ind].set_func) (mode);
+           (*shopt_vars[ind].set_func) (shopt_vars[ind].name, mode);
        }
     }
+
+  set_bashopts ();
   return (rval);
 }
 
@@ -316,7 +404,7 @@ list_shopts (list, flags)
          if ((flags & QFLAG) == 0)
            print_shopt (shopt_vars[i].name, val, flags);
        }
-      return (EXECUTION_SUCCESS);
+      return (sh_chkwrite (EXECUTION_SUCCESS));
     }
 
   for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)
@@ -324,7 +412,7 @@ list_shopts (list, flags)
       i = find_shopt (l->word->word);
       if (i < 0)
        {
-         SHOPT_ERROR (l->word->word);
+         shopt_error (l->word->word);
          rval = EXECUTION_FAILURE;
          continue;
        }
@@ -335,7 +423,7 @@ list_shopts (list, flags)
        print_shopt (l->word->word, val, flags);
     }
 
-  return (rval);
+  return (sh_chkwrite (rval));
 }
 
 static int
@@ -350,7 +438,7 @@ list_some_shopts (mode, flags)
       if (((flags & QFLAG) == 0) && mode == val)
        print_shopt (shopt_vars[i].name, val, flags);
     }
-  return (EXECUTION_SUCCESS);
+  return (sh_chkwrite (EXECUTION_SUCCESS));
 }
 
 static int
@@ -365,7 +453,7 @@ list_shopt_o_options (list, flags)
     {
       if ((flags & QFLAG) == 0)
        list_minus_o_opts (-1, (flags & PFLAG));
-      return (EXECUTION_SUCCESS);
+      return (sh_chkwrite (EXECUTION_SUCCESS));
     }
 
   for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)
@@ -373,7 +461,7 @@ list_shopt_o_options (list, flags)
       val = minus_o_option_value (l->word->word);
       if (val == -1)
        {
-         builtin_error ("%s: unknown option name", l->word->word);
+         sh_invalidoptname (l->word->word);
          rval = EXECUTION_FAILURE;
          continue;
        }
@@ -387,7 +475,7 @@ list_shopt_o_options (list, flags)
            printf (OPTFMT, l->word->word, val ? on : off);
        }
     }
-  return (rval);
+  return (sh_chkwrite (rval));
 }
 
 static int
@@ -396,7 +484,7 @@ list_some_o_options (mode, flags)
 {
   if ((flags & QFLAG) == 0)
     list_minus_o_opts (mode, (flags & PFLAG));
-  return (EXECUTION_SUCCESS);
+  return (sh_chkwrite (EXECUTION_SUCCESS));
 }
 
 static int
@@ -420,18 +508,97 @@ set_shopt_o_options (mode, list, quiet)
 /* If we set or unset interactive_comments with shopt, make sure the
    change is reflected in $SHELLOPTS. */
 static int
-set_interactive_comments (mode)
+set_shellopts_after_change (option_name, mode)
+     char *option_name;
      int mode;
 {
   set_shellopts ();
   return (0);
 }
 
+static int
+shopt_enable_hostname_completion (option_name, mode)
+     char *option_name;
+     int mode;
+{
+  return (enable_hostname_completion (mode));
+}
+
+static int
+set_compatibility_level (option_name, mode)
+     char *option_name;
+     int mode;
+{
+  int ind;
+
+  /* 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)
+    shell_compatibility_level = 31;
+  else if (shopt_compat32)
+    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)
+     char *option_name;
+     int mode;
+{
+  set_directory_hook ();
+  return 0;
+}
+#endif
+
 #if defined (RESTRICTED_SHELL)
 /* Don't allow the value of restricted_shell to be modified. */
 
 static int
-set_restricted_shell (mode)
+set_restricted_shell (option_name, mode)
+     char *option_name;
      int mode;
 {
   static int save_restricted = -1;
@@ -444,6 +611,16 @@ set_restricted_shell (mode)
 }
 #endif /* RESTRICTED_SHELL */
 
+/* Not static so shell.c can call it to initialize shopt_login_shell */
+int
+set_login_shell (option_name, mode)
+     char *option_name;
+     int mode;
+{
+  shopt_login_shell = login_shell != 0;
+  return (0);
+}
+
 char **
 get_shopt_options ()
 {
@@ -451,9 +628,150 @@ get_shopt_options ()
   int n, i;
 
   n = sizeof (shopt_vars) / sizeof (shopt_vars[0]);
-  ret = alloc_array (n + 1);
+  ret = strvec_create (n + 1);
   for (i = 0; shopt_vars[i].name; i++)
     ret[i] = savestring (shopt_vars[i].name);
   ret[i] = (char *)NULL;
   return ret;
 }
+
+/*
+ * External interface for other parts of the shell.  NAME is a string option;
+ * MODE is 0 if we want to unset an option; 1 if we want to set an option.
+ * REUSABLE is 1 if we want to print output in a form that may be reused.
+ */
+int
+shopt_setopt (name, mode)
+     char *name;
+     int mode;
+{
+  WORD_LIST *wl;
+  int r;
+
+  wl = add_string_to_list (name, (WORD_LIST *)NULL);
+  r = toggle_shopts (mode, wl, 0);
+  dispose_words (wl);
+  return r;
+}
+
+int
+shopt_listopt (name, reusable)
+     char *name;
+     int reusable;
+{
+  int i;
+
+  if (name == 0)
+    return (list_shopts ((WORD_LIST *)NULL, reusable ? PFLAG : 0));
+
+  i = find_shopt (name);
+  if (i < 0)
+    {
+      shopt_error (name);
+      return (EXECUTION_FAILURE);
+    }
+
+  print_shopt (name, *shopt_vars[i].value, reusable ? PFLAG : 0);
+  return (sh_chkwrite (EXECUTION_SUCCESS));
+}
+
+void
+set_bashopts ()
+{
+  char *value;
+  char tflag[N_SHOPT_OPTIONS];
+  int vsize, i, vptr, *ip, exported;
+  SHELL_VAR *v;
+
+  for (vsize = i = 0; shopt_vars[i].name; i++)
+    {
+      tflag[i] = 0;
+      if (GET_SHOPT_OPTION_VALUE (i))
+       {
+         vsize += strlen (shopt_vars[i].name) + 1;
+         tflag[i] = 1;
+       }
+    }
+
+  value = (char *)xmalloc (vsize + 1);
+
+  for (i = vptr = 0; shopt_vars[i].name; i++)
+    {
+      if (tflag[i])
+       {
+         strcpy (value + vptr, shopt_vars[i].name);
+         vptr += strlen (shopt_vars[i].name);
+         value[vptr++] = ':';
+       }
+    }
+
+  if (vptr)
+    vptr--;                    /* cut off trailing colon */
+  value[vptr] = '\0';
+
+  v = find_variable ("BASHOPTS");
+
+  /* Turn off the read-only attribute so we can bind the new value, and
+     note whether or not the variable was exported. */
+  if (v)
+    {
+      VUNSETATTR (v, att_readonly);
+      exported = exported_p (v);
+    }
+  else
+    exported = 0;
+
+  v = bind_variable ("BASHOPTS", value, 0);
+
+  /* Turn the read-only attribute back on, and turn off the export attribute
+     if it was set implicitly by mark_modified_vars and SHELLOPTS was not
+     exported before we bound the new value. */
+  VSETATTR (v, att_readonly);
+  if (mark_modified_vars && exported == 0 && exported_p (v))
+    VUNSETATTR (v, att_exported);
+
+  free (value);
+}
+
+void
+parse_bashopts (value)
+     char *value;
+{
+  char *vname;
+  int vptr, ind;
+
+  vptr = 0;
+  while (vname = extract_colon_unit (value, &vptr))
+    {
+      ind = find_shopt (vname);
+      if (ind >= 0)
+        *shopt_vars[ind].value = 1;
+      free (vname);
+    }
+}
+
+void
+initialize_bashopts (no_bashopts)
+     int no_bashopts;
+{
+  char *temp;
+  SHELL_VAR *var;
+
+  if (no_bashopts == 0)
+    {
+      var = find_variable ("BASHOPTS");
+      /* set up any shell options we may have inherited. */
+      if (var && imported_p (var))
+       {
+         temp = (array_p (var) || assoc_p (var)) ? (char *)NULL : savestring (value_cell (var));
+         if (temp)
+           {
+             parse_bashopts (temp);
+             free (temp);
+           }
+       }
+    }
+
+  /* Set up the $BASHOPTS variable. */
+  set_bashopts ();
+}