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

📄 shopt.def

📁 android-w.song.android.widget
💻 DEF
📖 第 1 页 / 共 2 页
字号:
static voidprint_shopt (name, val, flags)     char *name;     int val, flags;{  if (flags & PFLAG)    printf ("shopt %s %s\n", val ? "-s" : "-u", name);  else    printf (OPTFMT, name, val ? on : off);}/* List the values of all or any of the `shopt' options.  Returns 0 if   all were listed or all variables queried were on; 1 otherwise. */static intlist_shopts (list, flags)     WORD_LIST *list;     int flags;{  WORD_LIST *l;  int i, val, rval;  if (list == 0)    {      for (i = 0; shopt_vars[i].name; i++)	{	  val = *shopt_vars[i].value;	  if ((flags & QFLAG) == 0)	    print_shopt (shopt_vars[i].name, val, flags);	}      return (sh_chkwrite (EXECUTION_SUCCESS));    }  for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)    {      i = find_shopt (l->word->word);      if (i < 0)	{	  shopt_error (l->word->word);	  rval = EXECUTION_FAILURE;	  continue;	}      val = *shopt_vars[i].value;      if (val == 0)	rval = EXECUTION_FAILURE;      if ((flags & QFLAG) == 0)	print_shopt (l->word->word, val, flags);    }  return (sh_chkwrite (rval));}static intlist_some_shopts (mode, flags)     int mode, flags;{  int val, i;  for (i = 0; shopt_vars[i].name; i++)    {      val = *shopt_vars[i].value;      if (((flags & QFLAG) == 0) && mode == val)	print_shopt (shopt_vars[i].name, val, flags);    }  return (sh_chkwrite (EXECUTION_SUCCESS));}static intlist_shopt_o_options (list, flags)     WORD_LIST *list;     int flags;{  WORD_LIST *l;  int val, rval;  if (list == 0)    {      if ((flags & QFLAG) == 0)	list_minus_o_opts (-1, (flags & PFLAG));      return (sh_chkwrite (EXECUTION_SUCCESS));    }  for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)    {      val = minus_o_option_value (l->word->word);      if (val == -1)	{	  sh_invalidoptname (l->word->word);	  rval = EXECUTION_FAILURE;	  continue;	}      if (val == 0)	rval = EXECUTION_FAILURE;      if ((flags & QFLAG) == 0)	{	  if (flags & PFLAG)	    printf ("set %co %s\n", val ? '-' : '+', l->word->word);	  else	    printf (OPTFMT, l->word->word, val ? on : off);	}    }  return (sh_chkwrite (rval));}static intlist_some_o_options (mode, flags)     int mode, flags;{  if ((flags & QFLAG) == 0)    list_minus_o_opts (mode, (flags & PFLAG));  return (sh_chkwrite (EXECUTION_SUCCESS));}static intset_shopt_o_options (mode, list, quiet)     int mode;     WORD_LIST *list;     int quiet;{  WORD_LIST *l;  int rval;  for (l = list, rval = EXECUTION_SUCCESS; l; l = l->next)    {      if (set_minus_o_option (mode, l->word->word) == EXECUTION_FAILURE)	rval = EXECUTION_FAILURE;    }  set_shellopts ();  return rval;}/* If we set or unset interactive_comments with shopt, make sure the   change is reflected in $SHELLOPTS. */static intset_shellopts_after_change (option_name, mode)     char *option_name;     int mode;{  set_shellopts ();  return (0);}static intshopt_enable_hostname_completion (option_name, mode)     char *option_name;     int mode;{  return (enable_hostname_completion (mode));}static intset_compatibility_level (option_name, mode)     char *option_name;     int mode;{  /* Need to change logic here as we add more compatibility levels */  /* 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;  /* 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    shell_compatibility_level = DEFAULT_COMPAT_LEVEL;  return 0;}#if defined (RESTRICTED_SHELL)/* Don't allow the value of restricted_shell to be modified. */static intset_restricted_shell (option_name, mode)     char *option_name;     int mode;{  static int save_restricted = -1;  if (save_restricted == -1)    save_restricted = shell_is_restricted (shell_name);  restricted_shell = save_restricted;  return (0);}#endif /* RESTRICTED_SHELL *//* Not static so shell.c can call it to initialize shopt_login_shell */intset_login_shell (option_name, mode)     char *option_name;     int mode;{  shopt_login_shell = login_shell != 0;  return (0);}char **get_shopt_options (){  char **ret;  int n, i;  n = sizeof (shopt_vars) / sizeof (shopt_vars[0]);  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. */intshopt_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;}intshopt_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));}voidset_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);}voidparse_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);    }}voidinitialize_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 ();}

⌨️ 快捷键说明

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