⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shopt.def

📁 android-w.song.android.widget
💻 DEF
📖 第 1 页 / 共 2 页
字号:
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.This file is part of GNU Bash, the Bourne Again SHell.Bash is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe 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 ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with Bash.  If not, see <http://www.gnu.org/licenses/>.$PRODUCES shopt.c$BUILTIN shopt$FUNCTION shopt_builtin$SHORT_DOC shopt [-pqsu] [-o] [optname ...]Set and unset shell options.Change the setting of each shell option OPTNAME.  Without any optionarguments, list all shell options with an indication of whether or not eachis 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 OPTNAMEExit Status:Returns success if OPTNAME is enabled; fails if an invalid option isgiven or OPTNAME is disabled.$END#include <config.h>#if defined (HAVE_UNISTD_H)#  ifdef _MINIX#    include <sys/types.h>#  endif#  include <unistd.h>#endif#include <stdio.h>#include "version.h"#include "../bashintl.h"#include "../shell.h"#include "../flags.h"#include "common.h"#include "bashgetopt.h"#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, 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;extern int cdspelling, expand_aliases;extern int extended_quote;extern int check_window_size;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 lastpipe_opt;#if defined (EXTENDED_GLOB)extern int extended_glob;#endif#if defined (READLINE)extern int hist_verify, history_reediting, perform_hostname_completion;extern int no_empty_command_completion;extern int force_fignore;extern int dircomplete_spelling;extern int enable_hostname_completion __P((int));#endif#if defined (PROGRAMMABLE_COMPLETION)extern int prog_completion_enabled;#endif#if defined (RESTRICTED_SHELL)extern char *shell_name;#endif#if defined (DEBUGGER)extern int debugging_mode;#endifstatic void shopt_error __P((char *));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 __P((char *, int));#endifstatic int shopt_login_shell;static int shopt_compat31;static int shopt_compat32;static int shopt_compat40;static int shopt_compat41;typedef int shopt_set_func_t __P((char *, int));static struct {  char *name;  int  *value;  shopt_set_func_t *set_func;} shopt_vars[] = {  { "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, (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 },#if defined (READLINE)  { "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#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)  { "force_fignore", &force_fignore, (shopt_set_func_t *)NULL },#endif  { "globstar", &glob_star, (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 },#endif#if defined (READLINE)  { "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, (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, (shopt_set_func_t *)NULL },#endif  { "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, (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 },#endif  { "promptvars", &promptvars, (shopt_set_func_t *)NULL },#if defined (RESTRICTED_SHELL)  { "restricted_shell", &restricted_shell, set_restricted_shell },#endif  { "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 }};#define N_SHOPT_OPTIONS		(sizeof (shopt_vars) / sizeof (shopt_vars[0]))#define GET_SHOPT_OPTION_VALUE(i)	(*shopt_vars[i].value)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#define QFLAG	0x04#define OFLAG	0x08#define PFLAG	0x10intshopt_builtin (list)     WORD_LIST *list;{  int opt, flags, rval;  flags = 0;  reset_internal_getopt ();  while ((opt = internal_getopt (list, "psuoq")) != -1)    {      switch (opt)	{	case 's':	  flags |= SFLAG;	  break;	case 'u':	  flags |= UFLAG;	  break;	case 'q':	  flags |= QFLAG;	  break;	case 'o':	  flags |= OFLAG;	  break;	case 'p':	  flags |= PFLAG;	  break;	default:	  builtin_usage ();	  return (EX_USAGE);	}    }  list = loptend;  if ((flags & (SFLAG|UFLAG)) == (SFLAG|UFLAG))    {      builtin_error (_("cannot set and unset shell options simultaneously"));      return (EXECUTION_FAILURE);    }  rval = EXECUTION_SUCCESS;  if ((flags & OFLAG) && ((flags & (SFLAG|UFLAG)) == 0))	/* shopt -o */    rval = list_shopt_o_options (list, flags);  else if (list && (flags & OFLAG))		/* shopt -so args */    rval = set_shopt_o_options ((flags & SFLAG) ? FLAG_ON : FLAG_OFF, list, flags & QFLAG);  else if (flags & OFLAG)	/* shopt -so */    rval = list_some_o_options ((flags & SFLAG) ? 1 : 0, flags);  else if (list && (flags & (SFLAG|UFLAG)))	/* shopt -su args */    rval = toggle_shopts ((flags & SFLAG) ? SETOPT : UNSETOPT, list, flags & QFLAG);  else if ((flags & (SFLAG|UFLAG)) == 0)	/* shopt [args] */    rval = list_shopts (list, flags);  else						/* shopt -su */    rval = list_some_shopts ((flags & SFLAG) ? SETOPT : UNSETOPT, flags);  return (rval);}/* Reset the options managed by `shopt' to the values they would have at   shell startup. */voidreset_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;  source_uses_path = promptvars = 1;#if defined (EXTENDED_GLOB)  extended_glob = 0;#endif#if defined (HISTORY)  literal_history = force_append_history = 0;  command_oriented_history = 1;#endif#if defined (READLINE)  hist_verify = history_reediting = 0;  perform_hostname_completion = 1;#endif  shopt_login_shell = login_shell;}static intfind_shopt (name)     char *name;{  int i;  for (i = 0; shopt_vars[i].name; i++)    if (STREQ (name, shopt_vars[i].name))      return i;  return -1;}static voidshopt_error (s)     char *s;{  builtin_error (_("%s: invalid shell option name"), s);}static inttoggle_shopts (mode, list, quiet)     int mode;     WORD_LIST *list;     int quiet;{  WORD_LIST *l;  int ind, rval;  for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)    {      ind = find_shopt (l->word->word);      if (ind < 0)	{	  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) (shopt_vars[ind].name, mode);	}    }  set_bashopts ();  return (rval);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -