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

📄 set.def

📁 android-w.song.android.widget
💻 DEF
📖 第 1 页 / 共 2 页
字号:
		  return (EXECUTION_FAILURE);		}	      else		return (EXECUTION_SUCCESS);	    }	}    }  sh_invalidoptname (option_name);  return (EX_USAGE);}static voidprint_all_shell_variables (){  SHELL_VAR **vars;  vars = all_shell_variables ();  if (vars)    {      print_var_list (vars);      free (vars);    }  /* POSIX.2 does not allow function names and definitions to be output when     `set' is invoked without options (PASC Interp #202). */  if (posixly_correct == 0)    {      vars = all_shell_functions ();      if (vars)	{	  print_func_list (vars);	  free (vars);	}    }}voidset_shellopts (){  char *value;  char tflag[N_O_OPTIONS];  int vsize, i, vptr, *ip, exported;  SHELL_VAR *v;  for (vsize = i = 0; o_options[i].name; i++)    {      tflag[i] = 0;      if (o_options[i].letter)	{	  ip = find_flag (o_options[i].letter);	  if (ip && *ip)	    {	      vsize += strlen (o_options[i].name) + 1;	      tflag[i] = 1;	    }	}      else if (GET_BINARY_O_OPTION_VALUE (i, o_options[i].name))	{	  vsize += strlen (o_options[i].name) + 1;	  tflag[i] = 1;	}    }  value = (char *)xmalloc (vsize + 1);  for (i = vptr = 0; o_options[i].name; i++)    {      if (tflag[i])	{	  strcpy (value + vptr, o_options[i].name);	  vptr += strlen (o_options[i].name);	  value[vptr++] = ':';	}    }  if (vptr)    vptr--;			/* cut off trailing colon */  value[vptr] = '\0';  v = find_variable ("SHELLOPTS");  /* 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 ("SHELLOPTS", 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_shellopts (value)     char *value;{  char *vname;  int vptr;  vptr = 0;  while (vname = extract_colon_unit (value, &vptr))    {      set_minus_o_option (FLAG_ON, vname);      free (vname);    }}voidinitialize_shell_options (no_shellopts)     int no_shellopts;{  char *temp;  SHELL_VAR *var;  if (no_shellopts == 0)    {      var = find_variable ("SHELLOPTS");      /* 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_shellopts (temp);	      free (temp);	    }	}    }  /* Set up the $SHELLOPTS variable. */  set_shellopts ();}/* Reset the values of the -o options that are not also shell flags.  This is   called from execute_cmd.c:initialize_subshell() when setting up a subshell   to run an executable shell script without a leading `#!'. */voidreset_shell_options (){#if defined (HISTORY)  remember_on_history = enable_history_list = 1;#endif  ignoreeof = 0;}/* Set some flags from the word values in the input list.  If LIST is empty,   then print out the values of the variables instead.  If LIST contains   non-flags, then set $1 - $9 to the successive words of LIST. */intset_builtin (list)     WORD_LIST *list;{  int on_or_off, flag_name, force_assignment, opts_changed, rv, r;  register char *arg;  char s[3];  if (list == 0)    {      print_all_shell_variables ();      return (sh_chkwrite (EXECUTION_SUCCESS));    }  /* Check validity of flag arguments. */  rv = EXECUTION_SUCCESS;  reset_internal_getopt ();  while ((flag_name = internal_getopt (list, optflags)) != -1)    {      switch (flag_name)	{	  case '?':	    builtin_usage ();	    return (list_optopt == '?' ? EXECUTION_SUCCESS : EX_USAGE);	  default:	    break;	}    }      /* Do the set command.  While the list consists of words starting with     '-' or '+' treat them as flags, otherwise, start assigning them to     $1 ... $n. */  for (force_assignment = opts_changed = 0; list; )    {      arg = list->word->word;      /* If the argument is `--' or `-' then signal the end of the list	 and remember the remaining arguments. */      if (arg[0] == '-' && (!arg[1] || (arg[1] == '-' && !arg[2])))	{	  list = list->next;	  /* `set --' unsets the positional parameters. */	  if (arg[1] == '-')	    force_assignment = 1;	  /* Until told differently, the old shell behaviour of	     `set - [arg ...]' being equivalent to `set +xv [arg ...]'	     stands.  Posix.2 says the behaviour is marked as obsolescent. */	  else	    {	      change_flag ('x', '+');	      change_flag ('v', '+');	      opts_changed = 1;	    }	  break;	}      if ((on_or_off = *arg) && (on_or_off == '-' || on_or_off == '+'))	{	  while (flag_name = *++arg)	    {	      if (flag_name == '?')		{		  builtin_usage ();		  return (EXECUTION_SUCCESS);		}	      else if (flag_name == 'o') /* -+o option-name */		{		  char *option_name;		  WORD_LIST *opt;		  opt = list->next;		  if (opt == 0)		    {		      list_minus_o_opts (-1, (on_or_off == '+'));		      rv = sh_chkwrite (rv);		      continue;		    }		  option_name = opt->word->word;		  if (option_name == 0 || *option_name == '\0' ||		      *option_name == '-' || *option_name == '+')		    {		      list_minus_o_opts (-1, (on_or_off == '+'));		      continue;		    }		  list = list->next; /* Skip over option name. */		  opts_changed = 1;		  if ((r = set_minus_o_option (on_or_off, option_name)) != EXECUTION_SUCCESS)		    {		      set_shellopts ();		      return (r);		    }		}	      else if (change_flag (flag_name, on_or_off) == FLAG_ERROR)		{		  s[0] = on_or_off;		  s[1] = flag_name;		  s[2] = '\0';		  sh_invalidopt (s);		  builtin_usage ();		  set_shellopts ();		  return (EXECUTION_FAILURE);		}	      opts_changed = 1;	    }	}      else	{	  break;	}      list = list->next;    }  /* Assigning $1 ... $n */  if (list || force_assignment)    remember_args (list, 1);  /* Set up new value of $SHELLOPTS */  if (opts_changed)    set_shellopts ();  return (rv);}$BUILTIN unset$FUNCTION unset_builtin$SHORT_DOC unset [-f] [-v] [name ...]Unset values and attributes of shell variables and functions.For each NAME, remove the corresponding variable or function.Options:  -f	treat each NAME as a shell function  -v	treat each NAME as a shell variableWithout options, unset first tries to unset a variable, and if that fails,tries to unset a function.Some variables cannot be unset; also see `readonly'.Exit Status:Returns success unless an invalid option is given or a NAME is read-only.$END#define NEXT_VARIABLE()	any_failed++; list = list->next; continue;intunset_builtin (list)  WORD_LIST *list;{  int unset_function, unset_variable, unset_array, opt, any_failed;  char *name;  unset_function = unset_variable = unset_array = any_failed = 0;  reset_internal_getopt ();  while ((opt = internal_getopt (list, "fv")) != -1)    {      switch (opt)	{	case 'f':	  unset_function = 1;	  break;	case 'v':	  unset_variable = 1;	  break;	default:	  builtin_usage ();	  return (EX_USAGE);	}    }  list = loptend;  if (unset_function && unset_variable)    {      builtin_error (_("cannot simultaneously unset a function and a variable"));      return (EXECUTION_FAILURE);    }  while (list)    {      SHELL_VAR *var;      int tem;#if defined (ARRAY_VARS)      char *t;#endif      name = list->word->word;#if defined (ARRAY_VARS)      unset_array = 0;      if (!unset_function && valid_array_reference (name))	{	  t = strchr (name, '[');	  *t++ = '\0';	  unset_array++;	}#endif      /* Bash allows functions with names which are not valid identifiers	 to be created when not in posix mode, so check only when in posix	 mode when unsetting a function. */      if (((unset_function && posixly_correct) || !unset_function) && legal_identifier (name) == 0)	{	  sh_invalidid (name);	  NEXT_VARIABLE ();	}      var = unset_function ? find_function (name) : find_variable (name);      if (var && !unset_function && non_unsettable_p (var))	{	  builtin_error (_("%s: cannot unset"), name);	  NEXT_VARIABLE ();	}      /* Posix.2 says that unsetting readonly variables is an error. */      if (var && readonly_p (var))	{	  builtin_error (_("%s: cannot unset: readonly %s"),			 name, unset_function ? "function" : "variable");	  NEXT_VARIABLE ();	}      /* Unless the -f option is supplied, the name refers to a variable. */#if defined (ARRAY_VARS)      if (var && unset_array)	{	  if (array_p (var) == 0 && assoc_p (var) == 0)	    {	      builtin_error (_("%s: not an array variable"), name);	      NEXT_VARIABLE ();	    }	  else	    {	      tem = unbind_array_element (var, t);	      if (tem == -1)		any_failed++;	    }	}      else#endif /* ARRAY_VARS */      tem = unset_function ? unbind_func (name) : unbind_variable (name);      /* This is what Posix.2 draft 11+ says.  ``If neither -f nor -v	 is specified, the name refers to a variable; if a variable by	 that name does not exist, a function by that name, if any,	 shall be unset.'' */      if (tem == -1 && !unset_function && !unset_variable)	tem = unbind_func (name);      /* SUSv3, POSIX.1-2001 say:  ``Unsetting a variable or function that	 was not previously set shall not be considered an error.'' */      if (unset_function == 0)	stupidly_hack_special_variables (name);      list = list->next;    }  return (any_failed ? EXECUTION_FAILURE : EXECUTION_SUCCESS);}

⌨️ 快捷键说明

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