Hi All,

Solaris doesn't implement getcwd() with support for dynamic allocation
of memory. This BASH consider as broken so that configure defines
GETCWD_BROKEN.

Later in bash-3.2/config-bot.h it disables HAVE_GETCWD completely:

/* If we have a getcwd(3), but it calls popen(), #undef HAVE_GETCWD so
   the replacement in getcwd.c will be built. */
#if defined (HAVE_GETCWD) && defined (GETCWD_BROKEN)
#  undef HAVE_GETCWD
#endif

This forces BASH on Solaris to use internal implementation of getcwd()
from bash-3.2/lib/sh/getcwd.c. Unfortunately this implementation has
some problems and fails (returns NULL) at very specific situation of
loop back mounting. It can be fixed but it would bring to this source
code not very nice platform specific code.

Much more easier is to use Solaris native implementation of getcwd()
which works at all cases correctly. Please consider following patch for
bash 3.0 (where I did the testing) as something for beginning of discussion (I don't know the history of the whole thing):

--- bash-3.0/builtins/common.c.orig     Tue Jan 16 07:23:51 2007
+++ bash-3.0/builtins/common.c  Tue Jan 16 07:25:08 2007
@@ -472,7 +472,11 @@

   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"),
--- bash-3.0/config-bot.h.orig  Tue Jan 16 07:23:35 2007
+++ bash-3.0/config-bot.h       Tue Jan 16 07:24:52 2007
@@ -70,11 +70,13 @@
 #  define TERMIOS_MISSING
 #endif

+#if 0
 /* If we have a getcwd(3), but it calls popen(), #undef HAVE_GETCWD so
    the replacement in getcwd.c will be built. */
 #if defined (HAVE_GETCWD) && defined (GETCWD_BROKEN)
 #  undef HAVE_GETCWD
 #endif
+#endif

 #if !defined (HAVE_DEV_FD) && defined (NAMED_PIPES_MISSING)
 #  undef PROCESS_SUBSTITUTION


---

Any comments are welcomed.

Thanks,

Petr




_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to