zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: pws-25: saving old shell functions from overwriting
@ 1999-07-04 13:25 Peter Stephenson
  1999-07-09 10:30 ` Andrej Borsenkow
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Stephenson @ 1999-07-04 13:25 UTC (permalink / raw)
  To: Zsh hackers list

I half promised this some time ago.  When installing shell functions, an
existing shell function of the same name which differs from the new one is
moved to the file `.old'.  This is likely to be unnecessary if the function
came from a previous zsh distribution, but it's impossible to tell if it's
been modified locally, so this is safer.  We could alternatively have some
convention about how to recognise an unmodified distribution file, but
there's no guarantee people will stick to it.

The function installation code now has its own Config/ file.

I also tried to make the structure of the INSTALL file more transparent.

--- Completion/Makefile.in.old	Sun Jul  4 14:34:04 1999
+++ Completion/Makefile.in	Sun Jul  4 14:45:32 1999
@@ -48,40 +48,7 @@
 
 uninstall: uninstall.fns
 
-# install functions, including those in subdirectories, creating
-# install directory if necessary
-install.fns:
-	if test x$(fndir) != x && test x$(fndir) != xno; then \
-	  $(sdir_top)/mkinstalldirs $(fndir) || exit 1; \
-	  for file in $(FUNCTIONS_INSTALL); do \
-	    if test -f $$file; then \
-	      if test x$(FUNCTIONS_SUBDIRS) != x -a \
-	      x$(FUNCTIONS_SUBDIRS) != xno; then \
-	        subdir="`echo $$file | sed -e 's%/.*%%'`"; \
-	        $(sdir_top)/mkinstalldirs $(fndir)/$$subdir || exit 1; \
-	        $(INSTALL_DATA) $$file $(fndir)/$$subdir || exit 1; \
-	      else \
-	        $(INSTALL_DATA) $$file $(fndir) || exit 1; \
-	      fi; \
-	    fi; \
-	  done; \
-	fi; \
-	exit 0
-
-uninstall.fns:
-	if test x$(fndir) != x && test x$(fndir) != xno; then \
-	  for file in $(FUNCTIONS_INSTALL); do \
-	    if test -f $$file; then \
-	      if test x$(FUNCTIONS_SUBDIRS) != x -a \
-              x$(FUNCTIONS_SUBDIRS) != xno; then \
-	        rm -f $(fndir)/$$file; \
-	      else \
-	        rm -f "$(fndir)/`echo $$file | sed -e 's%^.*/%%'`"; \
-	      fi; \
-	    fi; \
-	  done; \
-	fi; \
-	exit 0
+@FUNCINST_MK@
 
 # ========== DEPENDENCIES FOR CLEANUP ==========
 
--- Config/funcinst.mk.old	Sun Jul  4 14:42:48 1999
+++ Config/funcinst.mk	Sun Jul  4 15:02:19 1999
@@ -0,0 +1,61 @@
+#
+# Makefile definitions for installing shell functions
+#
+# Copyright (c) 1999 Peter Stephenson
+# All rights reserved.
+#
+# Permission is hereby granted, without written agreement and without
+# license or royalty fees, to use, copy, modify, and distribute this
+# software and to distribute modified versions of this software for any
+# purpose, provided that the above copyright notice and the following
+# two paragraphs appear in all copies of this software.
+#
+# In no event shall Peter Stephenson or the Zsh Development Group be liable
+# to any party for direct, indirect, special, incidental, or consequential
+# damages arising out of the use of this software and its documentation,
+# even if Peter Stephenson and the Zsh Development Group have been advised of
+# the possibility of such damage.
+#
+# Peter Stephenson and the Zsh Development Group specifically disclaim any
+# warranties, including, but not limited to, the implied warranties of
+# merchantability and fitness for a particular purpose.  The software
+# provided hereunder is on an "as is" basis, and Peter Stephenson and the
+# Zsh Development Group have no obligation to provide maintenance,
+# support, updates, enhancements, or modifications.
+#
+
+# install functions, including those in subdirectories, creating
+# install directory if necessary
+
+install.fns:
+	if test x$(fndir) != x && test x$(fndir) != xno; then \
+	  $(sdir_top)/mkinstalldirs $(fndir) || exit 1; \
+	  for file in $(FUNCTIONS_INSTALL); do \
+	    if test -f $$file; then \
+	      if test x$(FUNCTIONS_SUBDIRS) != x -a \
+	      x$(FUNCTIONS_SUBDIRS) != xno; then \
+	        subdir="`echo $$file | sed -e 's%/.*%%'`"; \
+	        $(sdir_top)/mkinstalldirs $(fndir)/$$subdir || exit 1; \
+	        $(INSTALL_DATA) $$file $(fndir)/$$subdir || exit 1; \
+	      else \
+	        $(INSTALL_DATA) $$file $(fndir) || exit 1; \
+	      fi; \
+	    fi; \
+	  done; \
+	fi; \
+	exit 0
+
+uninstall.fns:
+	if test x$(fndir) != x && test x$(fndir) != xno; then \
+	  for file in $(FUNCTIONS_INSTALL); do \
+	    if test -f $$file; then \
+	      if test x$(FUNCTIONS_SUBDIRS) != x -a \
+	      x$(FUNCTIONS_SUBDIRS) != xno; then \
+	        rm -f $(fndir)/$$file; \
+	      else \
+	        rm -f "$(fndir)/`echo $$file | sed -e 's%^.*/%%'`"; \
+	      fi; \
+	    fi; \
+	  done; \
+	fi; \
+	exit 0
--- Functions/Makefile.in.old	Sun Jul  4 14:44:47 1999
+++ Functions/Makefile.in	Sun Jul  4 14:43:04 1999
@@ -48,40 +48,7 @@
 
 uninstall: uninstall.fns
 
-# install functions, including those in subdirectories, creating
-# install directory if necessary
-install.fns:
-	if test x$(fndir) != x && test x$(fndir) != xno; then \
-	  $(sdir_top)/mkinstalldirs $(fndir) || exit 1; \
-	  for file in $(FUNCTIONS_INSTALL); do \
-	    if test -f $$file; then \
-	      if test x$(FUNCTIONS_SUBDIRS) != x -a \
-	      x$(FUNCTIONS_SUBDIRS) != xno; then \
-	        subdir="`echo $$file | sed -e 's%/.*%%'`"; \
-	        $(sdir_top)/mkinstalldirs $(fndir)/$$subdir || exit 1; \
-	        $(INSTALL_DATA) $$file $(fndir)/$$subdir || exit 1; \
-	      else \
-	        $(INSTALL_DATA) $$file $(fndir) || exit 1; \
-	      fi; \
-	    fi; \
-	  done; \
-	fi; \
-	exit 0
-
-uninstall.fns:
-	if test x$(fndir) != x && test x$(fndir) != xno; then \
-	  for file in $(FUNCTIONS_INSTALL); do \
-	    if test -f $$file; then \
-	      if test x$(FUNCTIONS_SUBDIRS) != x -a \
-	      x$(FUNCTIONS_SUBDIRS) != xno; then \
-	        rm -f $(fndir)/$$file; \
-	      else \
-	        rm -f "$(fndir)/`echo $$file | sed -e 's%^.*/%%'`"; \
-	      fi; \
-	    fi; \
-	  done; \
-	fi; \
-	exit 0
+@FUNCINST_MK@
 
 # ========== DEPENDENCIES FOR CLEANUP ==========
 
--- INSTALL.old	Mon Jun 14 17:52:15 1999
+++ INSTALL	Sun Jul  4 15:18:36 1999
@@ -1,6 +1,15 @@
---------------
-INSTALLING ZSH
---------------
+                        ++++++++++++++
+                        INSTALLING ZSH
+                        ++++++++++++++
+
+This file is divided into two parts:  making and installing the shell, and
+a description of various additional configuration options.  You should
+have a look at the items in the second part before following the
+instructions in the first.
+
+=====================
+MAKING AND INSTALLING
+=====================
 
 Check MACHINES File
 -------------------
@@ -156,6 +165,11 @@
     /usr/local/src/zsh-3.0/configure
     make
 
+
+=====================
+CONFIGURATION OPTIONS
+=====================
+
 Memory Routines
 ---------------
 
@@ -233,11 +247,20 @@
 miscellaneous functions with documentation in comments; the complete set
 of functions can be installed with
   FUNCTIONS_INSTALL='Core/* Base/* Builtins/* User/* Commands/* Misc/* Zftp/*'
+Note you should set this by hand to include `Zftp/*' if you have zftp
+compiled into a statically linked shell.
 
-You can also set --enable-function-subdirs to allow shell
-functions to be installed into subdirectories of the function directory,
-i.e. `Core/*' files will be installed into `FNDIR/Core', and so on.
-This also initialises $fpath/$FPATH appropriately.
+You can also use the configure option --enable-function-subdirs to allow
+shell functions to be installed into subdirectories of the function
+directory, i.e. `Core/*' files will be installed into `FNDIR/Core', and so
+on. This also initialises $fpath/$FPATH appropriately.
+
+An existing installed shell function which differs from the one to be
+installed will be moved to a file with the suffix `.old', and restored to
+the original name on `make uninstall'.  However, an existing shell function
+identical to the one to be installed will simply be deleted on `make
+uninstall'.  If the old functions came unchanged from a previous zsh
+distribution, the `.old' files may simply be deleted by hand.
 
 Support for large files and integers
 ------------------------------------
--- configure.in.old	Tue Jun 15 13:33:46 1999
+++ configure.in	Sun Jul  4 14:56:20 1999
@@ -1340,11 +1340,13 @@
 CONFIG_MK="${srcdir}/Config/config.mk"
 dnl defs.mk is in the build tree, not the source tree
 DEFS_MK="Config/defs.mk"
+FUNCINST_MK="Config/funcinst.mk"
 VERSION_MK="${srcdir}/Config/version.mk"
 
 AC_SUBST_FILE(CLEAN_MK)dnl
 AC_SUBST_FILE(CONFIG_MK)dnl
 AC_SUBST_FILE(DEFS_MK)dnl
+AC_SUBST_FILE(FUNCINST_MK)dnl
 AC_SUBST_FILE(VERSION_MK)dnl
 
 real_no_create=$no_create

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: PATCH: pws-25: saving old shell functions from overwriting
  1999-07-04 13:25 PATCH: pws-25: saving old shell functions from overwriting Peter Stephenson
@ 1999-07-09 10:30 ` Andrej Borsenkow
  1999-07-09 11:05   ` Oliver Kiddle
  0 siblings, 1 reply; 7+ messages in thread
From: Andrej Borsenkow @ 1999-07-09 10:30 UTC (permalink / raw)
  To: Peter Stephenson, Zsh hackers list

>
> I half promised this some time ago.  When installing shell functions, an
> existing shell function of the same name which differs from the new one is
> moved to the file `.old'.  This is likely to be unnecessary if the function
> came from a previous zsh distribution, but it's impossible to tell if it's
> been modified locally, so this is safer.  We could alternatively have some
> convention about how to recognise an unmodified distribution file, but
> there's no guarantee people will stick to it.
>

I just realised, that it may be better to save the whole directory (in
functions.old probably). Moving files to *.old has potential problem, that if
anybody autloads whole $fpath, he will suddenly get a lot of fn.old functions.

/andrej


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH: pws-25: saving old shell functions from overwriting
  1999-07-09 10:30 ` Andrej Borsenkow
@ 1999-07-09 11:05   ` Oliver Kiddle
  1999-07-09 11:15     ` Andrej Borsenkow
  1999-07-09 12:25     ` PATCH: pws-25: old shell functions again Peter Stephenson
  0 siblings, 2 replies; 7+ messages in thread
From: Oliver Kiddle @ 1999-07-09 11:05 UTC (permalink / raw)
  To: Andrej Borsenkow; +Cc: Zsh hackers list

Andrej Borsenkow wrote:

> I just realised, that it may be better to save the whole directory (in
> functions.old probably). Moving files to *.old has potential problem, that if
> anybody autloads whole $fpath, he will suddenly get a lot of fn.old functions.

One thing which I would like changed is for compinit to add directories
to the end of $fpath instead of the beginning. This way, I can override
the zsh supplied completions with my own. By putting them in a different
directory, I don't have to worry about them being overwritten when I
install a new zsh. I would also be tempted to prefix the zsh completion
directories with a 'Z' so that compinit would put other directories in
/usr/local/share/zsh/functions (such as one named 'Local') first in
$fpath.

A result of the latest compinstall seems to be that I get the Core
directory duplicated in my $fpath. The compinstall created .zshrc adds
it so that it can autoload compinit and compinit then adds it in again.

Oliver Kiddle


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: PATCH: pws-25: saving old shell functions from overwriting
  1999-07-09 11:05   ` Oliver Kiddle
@ 1999-07-09 11:15     ` Andrej Borsenkow
  1999-07-09 12:25     ` PATCH: pws-25: old shell functions again Peter Stephenson
  1 sibling, 0 replies; 7+ messages in thread
From: Andrej Borsenkow @ 1999-07-09 11:15 UTC (permalink / raw)
  To: Oliver Kiddle; +Cc: Zsh hackers list

> 
> A result of the latest compinstall seems to be that I get the Core
> directory duplicated in my $fpath. The compinstall created .zshrc adds
> it so that it can autoload compinit and compinit then adds it in again.
> 


typeset -U fpath

always useful :-)


^ permalink raw reply	[flat|nested] 7+ messages in thread

* PATCH: pws-25: old shell functions again
  1999-07-09 11:05   ` Oliver Kiddle
  1999-07-09 11:15     ` Andrej Borsenkow
@ 1999-07-09 12:25     ` Peter Stephenson
  1999-07-09 13:00       ` Peter Stephenson
  1 sibling, 1 reply; 7+ messages in thread
From: Peter Stephenson @ 1999-07-09 12:25 UTC (permalink / raw)
  To: Zsh hackers list

Andrej Borsenkow wrote:
> I just realised, that it may be better to save the whole directory (in
> functions.old probably). Moving files to *.old has potential problem, that 
> if anybody autloads whole $fpath, he will suddenly get a lot of fn.old
> functions.

I was thinking about this too, but there may be other local files in the
functions hierarchy --- in fact, that's rather the intention.  This patch
is the latest idea.  (The claimed effect of the old patch has disappeared
from my copy of the source. Strange.)  If the function already exists and
is different, it gets moved into a corresponding place under functions.old
(for example, ..../functions/User/_rcs -> ..../functions.old/User/_rcs).
Then when uninstalling these all get moved back.  Thus old functions are
out of the load path, but functions not being installed are unaffected.

One slight hiccup here is that when uninstalling, files which existed
before but were unchanged are deleted.  That's because it seems pointless
to save identical files, but we then lose the memory of whether they were
there before.  This could be fixed by saving a date stamp at the start of
installation and only deleting files modified after on uninstallation.  I
haven't the strength to do that at the moment, but now installfns.sh is a
script it should be a bit more doable.

Oliver Kiddle wrote:
> One thing which I would like changed is for compinit to add directories
> to the end of $fpath instead of the beginning. This way, I can override
> the zsh supplied completions with my own.

Yes, I was wondering about that.  This changes it.

> I would also be tempted to prefix the zsh completion
> directories with a 'Z' so that compinit would put other directories in
> /usr/local/share/zsh/functions (such as one named 'Local') first in
> $fpath.

As we're already inside the zsh hierarchy, it seems a bit redundant to keep
adding more Z's.  You can have directories AALocal or 1Local, of course.

> A result of the latest compinstall seems to be that I get the Core
> directory duplicated in my $fpath. The compinstall created .zshrc adds
> it so that it can autoload compinit and compinit then adds it in again.

It was supposed to check, but there was a typo.

--- Completion/Core/compinit.finst	Thu Jul  8 10:38:51 1999
+++ Completion/Core/compinit	Fri Jul  9 14:11:57 1999
@@ -314,10 +314,10 @@
     fi
     for _i_line in {1..$#i_addfiles}; do
       _i_file=${_i_addfiles[$_i_line]}
-      [[ -d $_i_file && -z ${fpath[(r)$_i_$file]} ]] ||
+      [[ -d $_i_file && -z ${fpath[(r)$_i_file]} ]] ||
         _i_addfiles[$_i_line]=
     done
-    fpath=($_i_addfiles $fpath)
+    fpath=($fpath $_i_addfiles)
     _i_files=( ${^~fpath:/.}/_(|*[^~])(N:t) )
   fi
 fi
--- Config/funcinst.mk.finst	Sun Jul  4 15:02:19 1999
+++ Config/funcinst.mk	Fri Jul  9 14:23:09 1999
@@ -29,33 +29,19 @@
 
 install.fns:
 	if test x$(fndir) != x && test x$(fndir) != xno; then \
-	  $(sdir_top)/mkinstalldirs $(fndir) || exit 1; \
-	  for file in $(FUNCTIONS_INSTALL); do \
-	    if test -f $$file; then \
-	      if test x$(FUNCTIONS_SUBDIRS) != x -a \
-	      x$(FUNCTIONS_SUBDIRS) != xno; then \
-	        subdir="`echo $$file | sed -e 's%/.*%%'`"; \
-	        $(sdir_top)/mkinstalldirs $(fndir)/$$subdir || exit 1; \
-	        $(INSTALL_DATA) $$file $(fndir)/$$subdir || exit 1; \
-	      else \
-	        $(INSTALL_DATA) $$file $(fndir) || exit 1; \
-	      fi; \
-	    fi; \
-	  done; \
+	  sdir_top="$(sdir_top)" fndir="$(fndir)" \
+	  FUNCTIONS_INSTALL="$(FUNCTIONS_INSTALL)" \
+	  FUNCTIONS_SUBDIRS="$(FUNCTIONS_SUBDIRS)" \
+	  INSTALL_DATA="$(INSTALL_DATA)" \
+	  $(SHELL) $(sdir_top)/Config/installfns.sh || exit 1; \
 	fi; \
 	exit 0
 
 uninstall.fns:
 	if test x$(fndir) != x && test x$(fndir) != xno; then \
-	  for file in $(FUNCTIONS_INSTALL); do \
-	    if test -f $$file; then \
-	      if test x$(FUNCTIONS_SUBDIRS) != x -a \
-	      x$(FUNCTIONS_SUBDIRS) != xno; then \
-	        rm -f $(fndir)/$$file; \
-	      else \
-	        rm -f "$(fndir)/`echo $$file | sed -e 's%^.*/%%'`"; \
-	      fi; \
-	    fi; \
-	  done; \
+	  fndir="$(fndir)" \
+	  FUNCTIONS_INSTALL="$(FUNCTIONS_INSTALL)" \
+	  FUNCTIONS_SUBDIRS="$(FUNCTIONS_SUBDIRS)" \
+	  $(SHELL) $(sdir_top)/Config/uninstallfns.sh || exit 1; \
 	fi; \
 	exit 0
--- Config/installfns.sh.finst	Fri Jul  9 14:04:42 1999
+++ Config/installfns.sh	Fri Jul  9 13:52:28 1999
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+if test -d $fndir.old; then
+  add_old=1
+fi
+
+$sdir_top/mkinstalldirs $fndir || exit 1;
+
+for file in $FUNCTIONS_INSTALL; do
+  if test -f $file; then
+    if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then
+      subfile="$file"
+      subdir="`echo $file | sed -e 's%/[^/]*$%%'`"
+      olddir="$fndir.old/$subdir"
+      instdir="$fndir/$subdir"
+    else
+      subfile="`echo $file | sed -e 's%^.*/%%'`"
+      olddir="$fndir.old"
+      instdir="$fndir"
+    fi
+    if test -f $fndir/$subfile; then
+      if cmp $fndir/$subfile $file >/dev/null; then :; else
+	$sdir_top/mkinstalldirs $olddir
+        mv $fndir/$subfile $olddir
+        : ${add_old:=1}
+      fi
+    fi
+    $sdir_top/mkinstalldirs $instdir || exit 1
+    $INSTALL_DATA $file $instdir || exit 1
+  fi
+done
+
+if test x$add_old != x1; then
+  rm -rf $fndir.old
+fi
+
+exit 0
--- Config/uninstallfns.sh.finst	Fri Jul  9 14:04:45 1999
+++ Config/uninstallfns.sh	Fri Jul  9 13:58:05 1999
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+for file in $FUNCTIONS_INSTALL; do
+  if test -f $file; then
+    if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then
+      rm -f $fndir/$file;
+    else
+      rm -f "$fndir/`echo $file | sed -e 's%^.*/%%'`"; \
+    fi
+  fi
+done
+
+if test -d $fndir.old; then
+  for f in $fndir.old/*; do
+    if test -d $f; then
+      for f2 in $f/*; do
+	mv $f2 $fndir/"`echo $f | sed -e 's%^.*/%%'`"
+      done
+    else
+      mv $f $fndir
+    fi
+  done
+  rm -rf $fndir.old
+fi
+
+exit 0
--- INSTALL.finst	Wed Jul  7 14:13:53 1999
+++ INSTALL	Fri Jul  9 14:10:29 1999
@@ -256,12 +256,16 @@
 directory, i.e. `Core/*' files will be installed into `FNDIR/Core', and so
 on. This also initialises $fpath/$FPATH appropriately.
 
-An existing installed shell function which differs from the one to be
-installed will be moved to a file with the suffix `.old', and restored to
-the original name on `make uninstall'.  However, an existing shell function
-identical to the one to be installed will simply be deleted on `make
-uninstall'.  If the old functions came unchanged from a previous zsh
-distribution, the `.old' files may simply be deleted by hand.
+On installation, any completion function which already exists but is
+different from the new version will be moved to a corresponding place in
+FNDIR.old; for example, if a different version of User/_rcs exists when
+installing into /usr/local/share/zsh/functions/User, the old one will be
+moved into /usr/local/share/zsh/functions.old/User.  The installer is
+responsible for recovering or deleting old functions which have been moved
+in this way.  On uninstallation, any newly installed functions (including
+those which existed before but were unchanged) will be deleted and the
+files in the FNDIR.old hierarchy moved back into FNDIR.  To preserve the
+entire old hierarchy, you should move or copy it before installation.
 
 Support for large files and integers
 ------------------------------------

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH: pws-25: old shell functions again
  1999-07-09 12:25     ` PATCH: pws-25: old shell functions again Peter Stephenson
@ 1999-07-09 13:00       ` Peter Stephenson
  1999-07-09 16:23         ` Peter Stephenson
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Stephenson @ 1999-07-09 13:00 UTC (permalink / raw)
  To: Zsh hackers list

You wouldn't believe how much fantastic fun this all is.  Not only did
installation fail when using VPATH (because files in shell functions don't
use that, of course), the .old directory got deleted too early because I
forgot it had to be there for two different Makefiles.

--- Config/funcinst.mk.fi2	Fri Jul  9 14:23:09 1999
+++ Config/funcinst.mk	Fri Jul  9 14:50:08 1999
@@ -29,7 +29,7 @@
 
 install.fns:
 	if test x$(fndir) != x && test x$(fndir) != xno; then \
-	  sdir_top="$(sdir_top)" fndir="$(fndir)" \
+	  sdir_top="$(sdir_top)" fndir="$(fndir)" sdir="$(sdir)" \
 	  FUNCTIONS_INSTALL="$(FUNCTIONS_INSTALL)" \
 	  FUNCTIONS_SUBDIRS="$(FUNCTIONS_SUBDIRS)" \
 	  INSTALL_DATA="$(INSTALL_DATA)" \
@@ -39,7 +39,7 @@
 
 uninstall.fns:
 	if test x$(fndir) != x && test x$(fndir) != xno; then \
-	  fndir="$(fndir)" \
+	  fndir="$(fndir)" sdir="$(sdir)" \
 	  FUNCTIONS_INSTALL="$(FUNCTIONS_INSTALL)" \
 	  FUNCTIONS_SUBDIRS="$(FUNCTIONS_SUBDIRS)" \
 	  $(SHELL) $(sdir_top)/Config/uninstallfns.sh || exit 1; \
--- Config/installfns.sh.fi2	Fri Jul  9 13:52:28 1999
+++ Config/installfns.sh	Fri Jul  9 14:51:48 1999
@@ -7,7 +7,7 @@
 $sdir_top/mkinstalldirs $fndir || exit 1;
 
 for file in $FUNCTIONS_INSTALL; do
-  if test -f $file; then
+  if test -f $sdir/$file; then
     if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then
       subfile="$file"
       subdir="`echo $file | sed -e 's%/[^/]*$%%'`"
@@ -19,14 +19,14 @@
       instdir="$fndir"
     fi
     if test -f $fndir/$subfile; then
-      if cmp $fndir/$subfile $file >/dev/null; then :; else
+      if cmp $fndir/$subfile $sdir/$file >/dev/null; then :; else
 	$sdir_top/mkinstalldirs $olddir
         mv $fndir/$subfile $olddir
         : ${add_old:=1}
       fi
     fi
     $sdir_top/mkinstalldirs $instdir || exit 1
-    $INSTALL_DATA $file $instdir || exit 1
+    $INSTALL_DATA $sdir/$file $instdir || exit 1
   fi
 done
 
--- Config/uninstallfns.sh.fi2	Fri Jul  9 13:58:05 1999
+++ Config/uninstallfns.sh	Fri Jul  9 14:54:51 1999
@@ -1,26 +1,20 @@
 #!/bin/sh
 
 for file in $FUNCTIONS_INSTALL; do
-  if test -f $file; then
+  if test -f $sdir/$file; then
     if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then
       rm -f $fndir/$file;
+      if test -f $fndir.old/$file; then
+	mv $fndir.old/$file $fndir/$file
+      fi
     else
-      rm -f "$fndir/`echo $file | sed -e 's%^.*/%%'`"; \
+      bfile="`echo $file | sed -e 's%^.*/%%'`"
+      rm -f "$fndir/$bfile"; \
+      if test -f $fndir.old/$bfile; then
+        mv $fndir.old/$bfile $fndir/$bfile
+      fi
     fi
   fi
 done
-
-if test -d $fndir.old; then
-  for f in $fndir.old/*; do
-    if test -d $f; then
-      for f2 in $f/*; do
-	mv $f2 $fndir/"`echo $f | sed -e 's%^.*/%%'`"
-      done
-    else
-      mv $f $fndir
-    fi
-  done
-  rm -rf $fndir.old
-fi
 
 exit 0

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH: pws-25: old shell functions again
  1999-07-09 13:00       ` Peter Stephenson
@ 1999-07-09 16:23         ` Peter Stephenson
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Stephenson @ 1999-07-09 16:23 UTC (permalink / raw)
  To: Zsh hackers list

Peter Stephenson wrote:
> You wouldn't believe how much fantastic fun this all is.

This time, the problem is that the globbing patterns don't get expanded
until too late if the functions are living in the original source tree.

--- Config/installfns.sh.yetagain	Fri Jul  9 14:51:48 1999
+++ Config/installfns.sh	Fri Jul  9 18:19:56 1999
@@ -6,7 +6,18 @@
 
 $sdir_top/mkinstalldirs $fndir || exit 1;
 
+# If the source directory is somewhere else, we need to force
+# the shell to expand it in that directory, then strip it off.
+install=
 for file in $FUNCTIONS_INSTALL; do
+  if test -f "$sdir/$file"; then
+    install="$install $file"
+  else
+    install="$install `echo $sdir/$file | sed -e \"s%$sdir/%%g\"`"
+  fi
+done
+
+for file in $install; do
   if test -f $sdir/$file; then
     if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then
       subfile="$file"
--- Config/uninstallfns.sh.yetagain	Fri Jul  9 15:00:32 1999
+++ Config/uninstallfns.sh	Fri Jul  9 18:20:17 1999
@@ -1,6 +1,17 @@
 #!/bin/sh
 
+# If the source directory is somewhere else, we need to force
+# the shell to expand it in that directory, then strip it off.
+install=
 for file in $FUNCTIONS_INSTALL; do
+  if test -f "$sdir/$file"; then
+    install="$install $file"
+  else
+    install="$install `echo $sdir/$file | sed -e \"s%$sdir/%%g\"`"
+  fi
+done
+
+for file in $install; do
   if test -f $sdir/$file; then
     if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then
       rm -f $fndir/$file;

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1999-07-09 16:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-04 13:25 PATCH: pws-25: saving old shell functions from overwriting Peter Stephenson
1999-07-09 10:30 ` Andrej Borsenkow
1999-07-09 11:05   ` Oliver Kiddle
1999-07-09 11:15     ` Andrej Borsenkow
1999-07-09 12:25     ` PATCH: pws-25: old shell functions again Peter Stephenson
1999-07-09 13:00       ` Peter Stephenson
1999-07-09 16:23         ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).