At Thu, 3 Jun 2010 14:27:26 -0700, Simon Gerraty <sjg%juniper.net@localhost> wrote: Subject: fix? for old pd-ksh file completion bug > > This bug has existed for many years now (I'm sure I fixed it about 10 > years ago ;-) > > If you have $HOME/tmp and it is the only thing in $HOME which starts > with tm, then > > echo $HOME/tm<TAB> (or ESC ESC for emacs) > > should expand to /homes/sjg/tmp/ > but what you get is /homes/sjg/tm<SPACE> > > The reason is that add_glob() in edit.c stops as soon as it hits '$'. > So it ends up returning "$HOME/tm" rather than "$HOME/tm*". > Removing that as per the patch below, fixes this bug, but I can't think > what it might break... > > --sjg > > Index: edit.c > =================================================================== > RCS file: /cvsroot/src/bin/ksh/edit.c,v > retrieving revision 1.21 > diff -u -p -r1.21 edit.c > --- edit.c 28 Jan 2007 20:20:25 -0000 1.21 > +++ edit.c 3 Jun 2010 21:19:31 -0000 > @@ -880,7 +880,7 @@ add_glob(str, slen) > for (s = toglob; *s; s++) { > if (*s == '\\' && s[1]) > s++; > - else if (*s == '*' || *s == '?' || *s == '$' > + else if (*s == '*' || *s == '?' > || (s[1] == '(' /*)*/ && strchr("*+?@!", *s))) > break; > else if (ISDIRSEP(*s)) > I replaced the '$' with a '[' at some point a long time ago for some reason I can no longer remember (probably based on fixes I saw in either OpenBSD or FreeBSD): @@ -880,11 +952,26 @@ for (s = toglob; *s; s++) { if (*s == '\\' && s[1]) s++; - else if (*s == '*' || *s == '?' || *s == '$' + else if (*s == '*' || *s == '[' || *s == '?' || (s[1] == '(' /*)*/ && strchr("*+?@!", *s))) break; else if (ISDIRSEP(*s)) It is just one of the edit.c fixes I've been using for quite a long time now and I haven't noticed any regression as a result of it. There are many other bugs too and the most complete fix is probably to replace pd-ksh with mksh and then we don't have to maintain quite so many local changes any more -- it actually still suffers the same bug, but also includes the '[' as I do. However in the case of mksh the fix can be propagated back upstream much more easily than with pd-ksh it seems. (In fact I'll probably replace pd-ksh with mksh in my own netbsd-5 builds.) -- Greg A. Woods Planix, Inc. <woods%planix.com@localhost> +1 416 218 0099 http://www.planix.com/
Attachment:
pgpErJilJfeiC.pgp
Description: PGP signature