Bash-4.4 distribution sources and documentation
This commit is contained in:
		
					parent
					
						
							
								30a978b7d8
							
						
					
				
			
			
				commit
				
					
						a0c0a00fc4
					
				
			
		
					 588 changed files with 130746 additions and 80164 deletions
				
			
		| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
This file is enable.def, from which is created enable.c.
 | 
			
		||||
It implements the builtin "enable" in Bash.
 | 
			
		||||
 | 
			
		||||
Copyright (C) 1987-2009 Free Software Foundation, Inc.
 | 
			
		||||
Copyright (C) 1987-2016 Free Software Foundation, Inc.
 | 
			
		||||
 | 
			
		||||
This file is part of GNU Bash, the Bourne Again SHell.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -66,6 +66,7 @@ $END
 | 
			
		|||
#include "../flags.h"
 | 
			
		||||
#include "common.h"
 | 
			
		||||
#include "bashgetopt.h"
 | 
			
		||||
#include "findcmd.h"
 | 
			
		||||
 | 
			
		||||
#if defined (PROGRAMMABLE_COMPLETION)
 | 
			
		||||
#  include "../pcomplete.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -92,6 +93,11 @@ static void delete_builtin __P((struct builtin *));
 | 
			
		|||
static int local_dlclose __P((void *));
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define STRUCT_SUFFIX	"_struct"
 | 
			
		||||
/* for now */
 | 
			
		||||
#define LOAD_SUFFIX	"_builtin_load"
 | 
			
		||||
#define UNLOAD_SUFFIX	"_builtin_unload"
 | 
			
		||||
 | 
			
		||||
static void list_some_builtins __P((int));
 | 
			
		||||
static int enable_shell_command __P((char *, int));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -145,6 +151,7 @@ enable_builtin (list)
 | 
			
		|||
	  builtin_error (_("dynamic loading not available"));
 | 
			
		||||
	  return (EX_USAGE);
 | 
			
		||||
#endif /* HAVE_DLCLOSE */
 | 
			
		||||
	CASE_HELPOPT;
 | 
			
		||||
	default:
 | 
			
		||||
	  builtin_usage ();
 | 
			
		||||
	  return (EX_USAGE);
 | 
			
		||||
| 
						 | 
				
			
			@ -290,9 +297,11 @@ dyn_load_builtin (list, flags, filename)
 | 
			
		|||
  WORD_LIST *l;
 | 
			
		||||
  void *handle;
 | 
			
		||||
  
 | 
			
		||||
  int total, size, new, replaced;
 | 
			
		||||
  char *struct_name, *name;
 | 
			
		||||
  int total, size, new, replaced, r;
 | 
			
		||||
  char *struct_name, *name, *funcname;
 | 
			
		||||
  sh_load_func_t *loadfunc;
 | 
			
		||||
  struct builtin **new_builtins, *b, *new_shell_builtins, *old_builtin;
 | 
			
		||||
  char *loadables_path, *load_path;
 | 
			
		||||
 | 
			
		||||
  if (list == 0)
 | 
			
		||||
    return (EXECUTION_FAILURE);
 | 
			
		||||
| 
						 | 
				
			
			@ -301,15 +310,39 @@ dyn_load_builtin (list, flags, filename)
 | 
			
		|||
#define RTLD_LAZY 1
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  handle = 0;
 | 
			
		||||
  if (absolute_program (filename) == 0)
 | 
			
		||||
    {
 | 
			
		||||
      loadables_path = get_string_value ("BASH_LOADABLES_PATH");
 | 
			
		||||
      if (loadables_path)
 | 
			
		||||
	{
 | 
			
		||||
	  load_path = find_in_path (filename, loadables_path, FS_NODIRS|FS_EXEC_PREFERRED);
 | 
			
		||||
	  if (load_path)
 | 
			
		||||
	    {
 | 
			
		||||
#if defined (_AIX)
 | 
			
		||||
  handle = dlopen (filename, RTLD_NOW|RTLD_GLOBAL);
 | 
			
		||||
	      handle = dlopen (load_path, RTLD_NOW|RTLD_GLOBAL);
 | 
			
		||||
#else
 | 
			
		||||
  handle = dlopen (filename, RTLD_LAZY);
 | 
			
		||||
	      handle = dlopen (load_path, RTLD_LAZY);
 | 
			
		||||
#endif /* !_AIX */
 | 
			
		||||
	      free (load_path);
 | 
			
		||||
	    }
 | 
			
		||||
	}
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  /* Fall back to current directory for now */
 | 
			
		||||
  if (handle == 0)
 | 
			
		||||
#if defined (_AIX)
 | 
			
		||||
    handle = dlopen (filename, RTLD_NOW|RTLD_GLOBAL);
 | 
			
		||||
#else
 | 
			
		||||
    handle = dlopen (filename, RTLD_LAZY);
 | 
			
		||||
#endif /* !_AIX */
 | 
			
		||||
 | 
			
		||||
  if (handle == 0)
 | 
			
		||||
    {
 | 
			
		||||
      builtin_error (_("cannot open shared object %s: %s"), filename, dlerror ());
 | 
			
		||||
      name = printable_filename (filename, 0);
 | 
			
		||||
      builtin_error (_("cannot open shared object %s: %s"), name, dlerror ());
 | 
			
		||||
      if (name != filename)
 | 
			
		||||
	free (name);
 | 
			
		||||
      return (EXECUTION_FAILURE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -327,18 +360,36 @@ dyn_load_builtin (list, flags, filename)
 | 
			
		|||
      size = strlen (name);
 | 
			
		||||
      struct_name = (char *)xmalloc (size + 8);
 | 
			
		||||
      strcpy (struct_name, name);
 | 
			
		||||
      strcpy (struct_name + size, "_struct");
 | 
			
		||||
      strcpy (struct_name + size, STRUCT_SUFFIX);
 | 
			
		||||
 | 
			
		||||
      b = (struct builtin *)dlsym (handle, struct_name);
 | 
			
		||||
      if (b == 0)
 | 
			
		||||
	{
 | 
			
		||||
	  name = printable_filename (filename, 0);
 | 
			
		||||
	  builtin_error (_("cannot find %s in shared object %s: %s"),
 | 
			
		||||
			  struct_name, filename, dlerror ());
 | 
			
		||||
			  struct_name, name, dlerror ());
 | 
			
		||||
	  if (name != filename)
 | 
			
		||||
	    free (name);
 | 
			
		||||
	  free (struct_name);
 | 
			
		||||
	  continue;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
      free (struct_name);
 | 
			
		||||
      funcname = xrealloc (struct_name, size + sizeof (LOAD_SUFFIX) + 1);
 | 
			
		||||
      strcpy (funcname, name);
 | 
			
		||||
      strcpy (funcname + size, LOAD_SUFFIX);
 | 
			
		||||
 | 
			
		||||
      loadfunc = (sh_load_func_t *)dlsym (handle, funcname);
 | 
			
		||||
      if (loadfunc)
 | 
			
		||||
	{
 | 
			
		||||
	  r = (*loadfunc) (name);
 | 
			
		||||
	  if (r == 0)
 | 
			
		||||
	    {
 | 
			
		||||
	      builtin_error (_("load function for %s returns failure (%d): not loaded"), name, r);
 | 
			
		||||
	      free (funcname);
 | 
			
		||||
	      continue;
 | 
			
		||||
	    }
 | 
			
		||||
	}
 | 
			
		||||
      free (funcname);
 | 
			
		||||
 | 
			
		||||
      b->flags &= ~STATIC_BUILTIN;
 | 
			
		||||
      if (flags & SPECIAL)
 | 
			
		||||
| 
						 | 
				
			
			@ -446,7 +497,9 @@ dyn_unload_builtin (name)
 | 
			
		|||
{
 | 
			
		||||
  struct builtin *b;
 | 
			
		||||
  void *handle;
 | 
			
		||||
  int ref, i;
 | 
			
		||||
  char *funcname;
 | 
			
		||||
  sh_unload_func_t *unloadfunc;
 | 
			
		||||
  int ref, i, size;
 | 
			
		||||
 | 
			
		||||
  b = builtin_address_internal (name, 1);
 | 
			
		||||
  if (b == 0)
 | 
			
		||||
| 
						 | 
				
			
			@ -467,6 +520,17 @@ dyn_unload_builtin (name)
 | 
			
		|||
	ref++;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  /* Call any unload function */
 | 
			
		||||
  size = strlen (name);
 | 
			
		||||
  funcname = xmalloc (size + sizeof (UNLOAD_SUFFIX) + 1);
 | 
			
		||||
  strcpy (funcname, name);
 | 
			
		||||
  strcpy (funcname + size, UNLOAD_SUFFIX);
 | 
			
		||||
 | 
			
		||||
  unloadfunc = (sh_unload_func_t *)dlsym (handle, funcname);
 | 
			
		||||
  if (unloadfunc)
 | 
			
		||||
    (*unloadfunc) (name);	/* void function */
 | 
			
		||||
  free (funcname);
 | 
			
		||||
 | 
			
		||||
  /* Don't remove the shared object unless the reference count of builtins
 | 
			
		||||
     using it drops to zero. */
 | 
			
		||||
  if (ref == 1 && local_dlclose (handle) != 0)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue