

Other format: [Raw text]

Re: [ITP] bash [Attn: readline maintainer]

Hash: SHA1

According to Corinna Vinschen on 5/23/2005 7:28 AM:
> This ITP alone is worth a gold star.  IIIIIGOOOOR!

Why, thanks!

>>  Also, does anyone know whether it would be wise
>>to make bash depend on libreadline6, libintl3, and libiconv, and if so,
>>how to go about doing that?  I can't figure out why my build of bash-3.0
>>is 3 times the size of bash-2.05b-17.

I was comparing apples to apples, and still don't know why bash-2.05b-17
was .5 meg, when bash-3.0-1 was 1.5 meg, both with the same cygcheck
dependencies, and both stripped.  But when linking against libintl3 and
libiconv, bash-3.0-2 is .5 meg.  The new bash-3.0-2, in addition to
dynamic linking, also has some // fixes that I will be proposing upstream.

NOTE, I can't link against libreadline6 until a patch is applied there and
libreadline6-5.0-2 is released.  Part of my // patches are against bash's
static copy of readline, and the attached patch needs to be reflected in
the full readline before the dynamic library can be used.  There are two
parts to the patch - first, filename completion printing was just plain
wrong with / vs // handling when printing visible stats (so the correct
list was being generated, but was having super-slow displays as it tried
to stat the wrong files).  Second is a speedup - filename completion
cannot afford to wait several seconds per failed stat("//server") on a
large network, but we can take the shortcut that if the completion list is
accurate (and it usually is, since it came from the much faster
readdir(//)), then blindly treating //server as a directory without the
stat is okay.

file	size	md5sum
	454630	d8f34f4204557f8c5c9b0560f090ad2e
	2491787	ed61318af67fd50dbe48334abb9c2048
	(prev: 2.05b-16, curr: 2.05b-17, test: 3.0-2)
	506	571fe2af0fc23022273751fb7991367b

Please upload this version, so people can actually test it.  I will be on
vacation the first three weeks of June, so I can react to feedback this
week, otherwise it will be a while before I can respond.

- --
Life is short - so eat dessert first!

Eric Blake   
Version: GnuPG v1.4.0 (Cygwin)
Comment: Public key at
Comment: Using GnuPG with Thunderbird -

diff -urN -x .build -x .inst -x .sinst bash-3.0-orig/lib/readline/complete.c bash-3.0/lib/readline/complete.c
--- bash-3.0-orig/lib/readline/complete.c	2004-07-01 11:57:58.000000000 -0600
+++ bash-3.0/lib/readline/complete.c	2005-05-25 05:19:40.000000000 -0600
@@ -1,6 +1,6 @@
 /* complete.c -- filename completion for readline. */
-/* Copyright (C) 1987-2004 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
    This file is part of the GNU Readline Library, a library for
    reading lines of text with interactive input and history editing.
@@ -478,6 +478,16 @@
   struct stat finfo;
   int character, r;
+#ifdef __CYGWIN__
+  /* Cygwin stat("//server") can take several seconds when the server is
+     non-responsive, all to find out it will always behave as a directory.
+     Although this shortcut may sometimes provide a false positive, it is
+     worth the speedup in time if all callers validated that FILENAME exists
+     from a (much faster) readdir rather than calling stat. */
+  if (filename[0] == '/' && filename[1] == '/' && ! strchr (&filename[2], '/'))
+    return '/';
 #if defined (HAVE_LSTAT) && defined (S_ISLNK)
   r = lstat (filename, &finfo);
@@ -707,8 +717,14 @@
 	     full_pathname being the empty string, we are trying to complete
 	     files in the root directory.  If we pass a null string to the
 	     bash directory completion hook, for example, it will expand it
-	     to the current directory.  We just want the `/'. */
-	  s = tilde_expand (full_pathname && *full_pathname ? full_pathname : "/");
+	     to the current directory.  We just want the `/'.  Be careful
+             that the user's "//" is distinct from "/", but more leading
+             slashes can be collapsed.  */
+	  s = tilde_expand (! full_pathname || *full_pathname == '\0' ? "/"
+                            : full_pathname[0] != '/' ? full_pathname
+                            : full_pathname[1] == '\0' ? "//"
+                            : full_pathname[1] == '/' && ! full_pathname[2]
+                            ? "/" : full_pathname);
 	  if (rl_directory_completion_hook)
 	    (*rl_directory_completion_hook) (&s);
@@ -716,7 +732,10 @@
 	  tlen = strlen (to_print);
 	  new_full_pathname = (char *)xmalloc (slen + tlen + 2);
 	  strcpy (new_full_pathname, s);
-	  new_full_pathname[slen] = '/';
+          if (s[slen - 1] == '/')
+            slen--;
+          else
+            new_full_pathname[slen] = '/';
 	  strcpy (new_full_pathname + slen + 1, to_print);
 #if defined (VISIBLE_STATS)
