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-2005 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
$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.
#include <stdio.h>
+#include "../bashintl.h"
+
#include "../shell.h"
#include "../flags.h"
#include "common.h"
#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;
#if defined (EXTENDED_GLOB)
extern int extended_glob;
#if defined (READLINE)
extern int hist_verify, history_reediting, perform_hostname_completion;
extern int no_empty_command_completion;
+extern int force_fignore;
extern int enable_hostname_completion __P((int));
#endif
#endif
#if defined (RESTRICTED_SHELL)
-extern int restricted_shell;
extern char *shell_name;
#endif
-static int set_interactive_comments __P((int));
+#if defined (DEBUGGER)
+extern int debugging_mode;
+#endif
+
+static void shopt_error __P((char *));
+
+static int set_shellopts_after_change __P((int));
+
+static int set_compatibility_level __P((int));
#if defined (RESTRICTED_SHELL)
static int set_restricted_shell __P((int));
#endif
static int shopt_login_shell;
+static int shopt_compat31;
typedef int shopt_set_func_t __P((int));
#if defined (HISTORY)
{ "cmdhist", &command_oriented_history, (shopt_set_func_t *)NULL },
#endif
+ { "compat31", &shopt_compat31, set_compatibility_level },
{ "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
#if defined (EXTENDED_GLOB)
{ "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, (shopt_set_func_t *)NULL },
+ { "force_fignore", &force_fignore, (shopt_set_func_t *)NULL },
#endif
+ { "gnu_errfmt", &gnu_error_format, (shopt_set_func_t *)NULL },
#if defined (HISTORY)
{ "histappend", &force_append_history, (shopt_set_func_t *)NULL },
#endif
#if defined (READLINE)
+ { "histreedit", &history_reediting, (shopt_set_func_t *)NULL },
{ "histverify", &hist_verify, (shopt_set_func_t *)NULL },
{ "hostcomplete", &perform_hostname_completion, enable_hostname_completion },
#endif
{ "huponexit", &hup_on_exit, (shopt_set_func_t *)NULL },
- { "interactive_comments", &interactive_comments, set_interactive_comments },
+ { "interactive_comments", &interactive_comments, set_shellopts_after_change },
#if defined (HISTORY)
{ "lithist", &literal_history, (shopt_set_func_t *)NULL },
#endif
{ "no_empty_cmd_completion", &no_empty_command_completion, (shopt_set_func_t *)NULL },
#endif
{ "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, (shopt_set_func_t *)NULL },
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);
}
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)
ind = find_shopt (l->word->word);
if (ind < 0)
{
- SHOPT_ERROR (l->word->word);
+ shopt_error (l->word->word);
rval = EXECUTION_FAILURE;
}
else
i = find_shopt (l->word->word);
if (i < 0)
{
- SHOPT_ERROR (l->word->word);
+ shopt_error (l->word->word);
rval = EXECUTION_FAILURE;
continue;
}
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;
}
/* 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 (mode)
int mode;
{
set_shellopts ();
return (0);
}
+static int
+set_compatibility_level (mode)
+ int mode;
+{
+ /* Need to change logic here as we add more compatibility levels */
+ if (shopt_compat31)
+ shell_compatibility_level = 31;
+ else
+ shell_compatibility_level = 32;
+ return 0;
+}
+
#if defined (RESTRICTED_SHELL)
/* Don't allow the value of restricted_shell to be modified. */
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;
i = find_shopt (name);
if (i < 0)
{
- SHOPT_ERROR (name);
+ shopt_error (name);
return (EXECUTION_FAILURE);
}