Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: pws-25: saving old shell functions from overwriting



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@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author