Imported from ../bash-4.0-rc1.tar.gz.
[platform/upstream/bash.git] / builtins / source.def
index f9f812f..72627db 100644 (file)
@@ -1,44 +1,55 @@
 This file is source.def, from which is created source.c.
 It implements the builtins "." and  "source" in Bash.
 
 This file is source.def, from which is created source.c.
 It implements the builtins "." and  "source" in Bash.
 
-Copyright (C) 1987-2003 Free Software Foundation, Inc.
+Copyright (C) 1987-2009 Free Software Foundation, Inc.
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
 
 This file is part of GNU Bash, the Bourne Again SHell.
 
-Bash is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
+Bash is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the 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 of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
+Bash is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
 
 
-You should have received a copy of the GNU General Public License along
-with Bash; see the file COPYING.  If not, write to the Free Software
-Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+You should have received a copy of the GNU General Public License
+along with Bash.  If not, see <http://www.gnu.org/licenses/>.
 
 $PRODUCES source.c
 
 $BUILTIN source
 $FUNCTION source_builtin
 $SHORT_DOC source filename [arguments]
 
 $PRODUCES source.c
 
 $BUILTIN source
 $FUNCTION source_builtin
 $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.  If any
-ARGUMENTS are supplied, they become the positional parameters when
-FILENAME is executed.
+Execute commands from a file in the current shell.
+
+Read and execute commands from FILENAME in the current shell.  The
+entries in $PATH are used to find the directory containing FILENAME.
+If any ARGUMENTS are supplied, they become the positional parameters
+when FILENAME is executed.
+
+Exit Status:
+Returns the status of the last command executed in FILENAME; fails if
+FILENAME cannot be read.
 $END
 $END
+
 $BUILTIN .
 $DOCNAME dot
 $FUNCTION source_builtin
 $SHORT_DOC . filename [arguments]
 $BUILTIN .
 $DOCNAME dot
 $FUNCTION source_builtin
 $SHORT_DOC . filename [arguments]
-Read and execute commands from FILENAME and return.  The pathnames
-in $PATH are used to find the directory containing FILENAME.  If any
-ARGUMENTS are supplied, they become the positional parameters when
-FILENAME is executed.
+Execute commands from a file in the current shell.
+
+Read and execute commands from FILENAME in the current shell.  The
+entries in $PATH are used to find the directory containing FILENAME.
+If any ARGUMENTS are supplied, they become the positional parameters
+when FILENAME is executed.
+
+Exit Status:
+Returns the status of the last command executed in FILENAME; fails if
+FILENAME cannot be read.
 $END
 $END
-/* source.c - Implements the `.' and `source' builtins. */
 
 #include <config.h>
 
 
 #include <config.h>
 
@@ -68,9 +79,9 @@ $END
 extern int errno;
 #endif /* !errno */
 
 extern int errno;
 #endif /* !errno */
 
-#if defined (RESTRICTED_SHELL)
-extern int restricted;
-#endif
+extern int posixly_correct;
+
+static void maybe_pop_dollar_vars __P((void));
 
 /* If non-zero, `.' uses $PATH to look up the script to be sourced. */
 int source_uses_path = 1;
 
 /* If non-zero, `.' uses $PATH to look up the script to be sourced. */
 int source_uses_path = 1;
@@ -128,7 +139,12 @@ source_builtin (list)
 #endif
 
   filename = (char *)NULL;
 #endif
 
   filename = (char *)NULL;
-  if (source_uses_path)
+  /* XXX -- should this be absolute_pathname? */
+  if (posixly_correct && strchr (list->word->word, '/'))
+    filename = savestring (list->word->word);
+  else if (absolute_pathname (list->word->word))
+    filename = savestring (list->word->word);
+  else if (source_uses_path)
     filename = find_path_file (list->word->word);
   if (filename == 0)
     {
     filename = find_path_file (list->word->word);
   if (filename == 0)
     {