Imported from ../bash-3.2.48.tar.gz.
[platform/upstream/bash.git] / builtins / common.c
index 7b9613e..89c6a87 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2007 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -131,6 +131,7 @@ no_args (list)
   if (list)
     {
       builtin_error (_("too many arguments"));
+      top_level_cleanup ();
       jump_to_top_level (DISCARD);
     }
 }
@@ -395,7 +396,10 @@ get_numeric_arg (list, fatal)
          if (fatal)
            throw_to_top_level ();
          else
-           jump_to_top_level (DISCARD);
+           {
+             top_level_cleanup ();
+             jump_to_top_level (DISCARD);
+           }
        }
       no_args (list->next);
     }
@@ -475,7 +479,11 @@ get_working_directory (for_whom)
 
   if (the_current_working_directory == 0)
     {
+#if defined (GETCWD_BROKEN)
+      the_current_working_directory = getcwd (0, PATH_MAX);
+#else
       the_current_working_directory = getcwd (0, 0);
+#endif
       if (the_current_working_directory == 0)
        {
          fprintf (stderr, _("%s: error retrieving current directory: %s: %s\n"),