Imported from ../bash-3.0.tar.gz.
This commit is contained in:
parent
7117c2d221
commit
b80f6443b6
400 changed files with 69247 additions and 13346 deletions
|
|
@ -1,7 +1,7 @@
|
|||
This file is source.def, from which is created source.c.
|
||||
It implements the builtins "." and "source" in Bash.
|
||||
|
||||
Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2003 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
|
|
@ -23,16 +23,20 @@ $PRODUCES source.c
|
|||
|
||||
$BUILTIN source
|
||||
$FUNCTION source_builtin
|
||||
$SHORT_DOC source filename
|
||||
$SHORT_DOC source filename [arguments]
|
||||
Read and execute commands from FILENAME and return. The pathnames
|
||||
in $PATH are used to find the directory containing FILENAME.
|
||||
in $PATH are used to find the directory containing FILENAME. If any
|
||||
ARGUMENTS are supplied, they become the positional parameters when
|
||||
FILENAME is executed.
|
||||
$END
|
||||
$BUILTIN .
|
||||
$DOCNAME dot
|
||||
$FUNCTION source_builtin
|
||||
$SHORT_DOC . filename
|
||||
$SHORT_DOC . filename [arguments]
|
||||
Read and execute commands from FILENAME and return. The pathnames
|
||||
in $PATH are used to find the directory containing FILENAME.
|
||||
in $PATH are used to find the directory containing FILENAME. If any
|
||||
ARGUMENTS are supplied, they become the positional parameters when
|
||||
FILENAME is executed.
|
||||
$END
|
||||
/* source.c - Implements the `.' and `source' builtins. */
|
||||
|
||||
|
|
@ -41,7 +45,7 @@ $END
|
|||
#include "../bashtypes.h"
|
||||
#include "posixstat.h"
|
||||
#include "filecntl.h"
|
||||
#ifndef _MINIX
|
||||
#if ! defined(_MINIX) && defined (HAVE_SYS_FILE_H)
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
|
|
@ -51,11 +55,14 @@ $END
|
|||
#endif
|
||||
|
||||
#include "../bashansi.h"
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../flags.h"
|
||||
#include "../findcmd.h"
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
#include "../trap.h"
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
|
|
@ -85,6 +92,8 @@ maybe_pop_dollar_vars ()
|
|||
dispose_saved_dollar_vars ();
|
||||
else
|
||||
pop_dollar_vars ();
|
||||
if (debugging_mode)
|
||||
pop_args (); /* restore BASH_ARGC and BASH_ARGV */
|
||||
set_dollar_vars_unchanged ();
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +106,7 @@ source_builtin (list)
|
|||
WORD_LIST *list;
|
||||
{
|
||||
int result;
|
||||
char *filename;
|
||||
char *filename, *debug_trap;
|
||||
|
||||
if (no_options (list))
|
||||
return (EX_USAGE);
|
||||
|
|
@ -105,7 +114,7 @@ source_builtin (list)
|
|||
|
||||
if (list == 0)
|
||||
{
|
||||
builtin_error ("filename argument required");
|
||||
builtin_error (_("filename argument required"));
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
|
|
@ -125,7 +134,7 @@ source_builtin (list)
|
|||
{
|
||||
if (source_searches_cwd == 0)
|
||||
{
|
||||
builtin_error ("%s: file not found", list->word->word);
|
||||
builtin_error (_("%s: file not found"), list->word->word);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
else
|
||||
|
|
@ -140,10 +149,24 @@ source_builtin (list)
|
|||
push_dollar_vars ();
|
||||
add_unwind_protect ((Function *)maybe_pop_dollar_vars, (char *)NULL);
|
||||
remember_args (list->next, 1);
|
||||
if (debugging_mode)
|
||||
push_args (list->next); /* Update BASH_ARGV and BASH_ARGC */
|
||||
}
|
||||
set_dollar_vars_unchanged ();
|
||||
|
||||
result = source_file (filename);
|
||||
/* Don't inherit the DEBUG trap unless function_trace_mode (overloaded)
|
||||
is set. XXX - should sourced files inherit the RETURN trap? Functions
|
||||
don't. */
|
||||
debug_trap = TRAP_STRING (DEBUG_TRAP);
|
||||
if (debug_trap && function_trace_mode == 0)
|
||||
{
|
||||
debug_trap = savestring (debug_trap);
|
||||
add_unwind_protect (xfree, debug_trap);
|
||||
add_unwind_protect (set_debug_trap, debug_trap);
|
||||
restore_default_signal (DEBUG_TRAP);
|
||||
}
|
||||
|
||||
result = source_file (filename, (list && list->next));
|
||||
|
||||
run_unwind_frame ("source");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue