bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Solaris getcwd() implementation vs BASH


From: Petr Sumbera
Subject: Solaris getcwd() implementation vs BASH
Date: Tue, 16 Jan 2007 18:14:16 +0100
User-agent: Thunderbird 1.5 (X11/20060113)

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 corectly. Please consider following patch for bash 3.0 (where I did the testing) as something for beginning of discussion:

--- 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. Please leave me always on copy since I'm not on the list.

Thanks,

Petr





reply via email to

[Prev in Thread] Current Thread [Next in Thread]