Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <42CE762F.20105@byu.net> Date: Fri, 08 Jul 2005 06:48:47 -0600 From: Eric Blake User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) MIME-Version: 1.0 To: bug-bash AT gnu DOT org CC: cygwin AT cygwin DOT com Subject: --with-installed-readline breaks tilde-expansion Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On the cygwin list, a difference was pointed out between compilations of bash that avoid or use --with-installed-readline: static_bash$ echo $HOME ~ /home/eblake /home/eblake static_bash$ HOME=/tmp; echo $HOME ~ /tmp /tmp dynamic_bash$ echo $HOME ~ /home/eblake /home/eblake dynamic_bash$ HOME=/tmp; echo $HOME ~ /tmp /home/eblake When compiling statically (without using --with-installed-readline), bash uses its own -ltilde, and sh_get_env_value resolves to bash's implementation in variable.c, which correctly searches bash's alternative environment. When compiling dynamically out of the box (using - --with-installed-readline), there is a link error of multiply defined symbols. The problem here is that bash wants to use the static -ltilde but the dynamic libreadline.dll; but since cygwin forbids dynamic libraries with undefined symbols, libreadline.dll was already compiled with -ltilde and all the symbols from -ltilde conflict with those from the dynamic library. My patch to this issue is below. When compiling dynamically with the patch applied, bash gets its tilde-expansion routines from the dynamic libreadline. Unfortunately, when compiling libreadline, sh_get_env_value resolves to readline's version in shell.c, which just calls getenv(). Cygwin does not allow bash's sh_get_env_value (or getenv) to override libreadline.dll's version (back to that no undefined symbol rule - tilde.c cannot link into a dynamic library with an import of sh_get_env_value unless sh_get_env_value is defined as part of the dynamic library). So tilde expansion is now stuck reading the global environ instead of bash's environment, and since bash does not update environ, tilde expansion is frozen to the value of $HOME at process invocation. I think the best solution would be a backwards-compatible extension to the tilde library. It should provide a new exported variable that defaults to NULL (in which case tilde_expand_word falls back to calling the imported sh_get_env_value), but which applications can set to override the calls to sh_get_env_value (and thus sh_get_home_dir). It could either be a char* (the current string representing HOME/home_dir in bash's notion of the environment) or a function pointer (a callback that lets bash compute the current HOME or home_dir every time it is needed), I'm not sure which of those two options would be easier for bash. This new export would bump the API version of readline (to 5.1?), and then compiling bash - --with-installed-readline would have to use this new entry point so that it can tell tilde_expand_word what to use so that tilde-expansion isn't stuck expanding from a stale environment. - --- bash-3.0-orig/configure.in 2004-07-21 14:06:54.000000000 -0600 +++ bash-3.0/configure.in 2005-05-24 20:29:34.000000000 -0600 @@ -487,14 +487,15 @@ esac ;; esac - - READLINE_DEP= + READLINE_DEP= TILDE_LIB= else RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline' READLINE_DEP='$(READLINE_LIBRARY)' + TILDE_LIB=-ltilde fi else RL_LIBDIR='$(dot)/$(LIBSUBDIR)/readline' - - READLINE_LIB= READLINE_DEP= + READLINE_LIB= READLINE_DEP= TILDE_LIB=-ltilde fi if test $opt_history = yes || test $opt_bang_history = yes; then if test $opt_history = yes; then @@ -528,6 +529,7 @@ AC_SUBST(RL_LIBDIR) AC_SUBST(RL_INCLUDEDIR) AC_SUBST(RL_INCLUDE) +AC_SUBST(TILDE_LIB) AC_SUBST(HISTORY_LIB) AC_SUBST(HISTORY_DEP) AC_SUBST(HIST_LIBDIR) - --- bash-3.0-orig/Makefile.in 2004-03-17 06:34:39.000000000 -0700 +++ bash-3.0/Makefile.in 2005-07-06 05:59:58.000000000 -0600 @@ -309,7 +309,7 @@ TILDE_LIBDIR = $(dot)/$(LIBSUBDIR)/tilde TILDE_ABSSRC = ${topdir}/$(TILDE_LIBDIR) - -TILDE_LIB = -ltilde +TILDE_LIB = @TILDE_LIB@ TILDE_LIBRARY = $(TILDE_LIBDIR)/libtilde.a TILDE_LDFLAGS = -L$(TILDE_LIBDIR) TILDE_DEP = $(TILDE_LIBRARY) - -- Life is short - so eat dessert first! Eric Blake ebb9 AT byu DOT net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCznYv84KuGfSFAYARAmw3AJ9Yam4HBCFu4zZ+93Tpwstt3CkkzgCcDG7X VGiwfFrmNtArlMztTtF8Cdk= =6Ifo -----END PGP SIGNATURE----- -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/