about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2005-07-20 18:08:39 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2005-07-20 18:08:39 +0000
commit3d5bececac2f5de845e56eb953ae8ab127e7904f (patch)
tree739be17480b8d7ae13eb4db6fc4c0cdabd87e2fb
parenta4e534dcbc8238ddf13a1102f21681ee8735adcf (diff)
downloadzsh-3d5bececac2f5de845e56eb953ae8ab127e7904f.tar.gz
zsh-3d5bececac2f5de845e56eb953ae8ab127e7904f.tar.xz
zsh-3d5bececac2f5de845e56eb953ae8ab127e7904f.zip
21500: Add script and function as framework for new user stuff.
-rw-r--r--ChangeLog7
-rwxr-xr-xConfig/installfns.sh13
-rwxr-xr-xConfig/uninstallfns.sh47
-rw-r--r--Functions/Newuser/zsh-install-newuser11
-rw-r--r--Makefile.in2
-rw-r--r--Scripts/newuser6
-rw-r--r--Src/Modules/newuser.mdd5
7 files changed, 75 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 092d87b3b..957135c0f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-07-20  Peter Stephenson  <pws@csr.com>
+
+	* 21500: Makefile.in, Config/installfns.sh,
+	Config/uninstallfns.sh, Functions/Newuser/zsh-install-newuser,
+	Scripts/newuser, Src/Modules/newuser.mdd: Add framework for
+	function to be edited to provide new user startup files.
+
 2005-07-20  Clint Adams  <clint@zsh.org>
 
 	* 21499: Doc/Makefile.in: use newer texi2html syntax.
diff --git a/Config/installfns.sh b/Config/installfns.sh
index 8dc1214b0..83f3cb6c1 100755
--- a/Config/installfns.sh
+++ b/Config/installfns.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 fndir=$DESTDIR$fndir
+scriptdir=$DESTDIR$scriptdir
 
 /bin/sh $sdir_top/mkinstalldirs $fndir || exit 1;
 
@@ -25,13 +26,23 @@ for file in $allfuncs; do
       Completion/*)
         instdir="$fndir/Completion"
         ;;
+      Scripts/*)
+        instdir="$scriptdir"
+	;;
       *)
         subdir="`echo $file | sed -e 's%/[^/]*$%%' -e 's%^Functions/%%'`"
         instdir="$fndir/$subdir"
         ;;
       esac
     else
-      instdir="$fndir"
+      case "$file" in
+      Scripts/*)
+        instdir="$scriptdir"
+	;;
+      *)
+        instdir="$fndir"
+        ;;
+      esac
     fi
     test -d $instdir || /bin/sh $sdir_top/mkinstalldirs $instdir || exit 1
     $INSTALL_DATA $sdir_top/$file $instdir || exit 1
diff --git a/Config/uninstallfns.sh b/Config/uninstallfns.sh
index c45c58b09..7c223889c 100755
--- a/Config/uninstallfns.sh
+++ b/Config/uninstallfns.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 fndir=$DESTDIR$fndir
+scriptdir=$DESTDIR$scriptdir
 
 allfuncs="`grep ' functions=' ${dir_top}/config.modules |
   sed -e '/^#/d' -e '/ link=no/d' -e 's/^.* functions=//'`"
@@ -10,10 +11,6 @@ allfuncs="`cd ${sdir_top}; echo ${allfuncs}`"
 case $fndir in
   *$VERSION*)
      # Version specific function directory, safe to remove completely.
-     # However, we don't remove the top-level version directory since
-     # it could have other things than functions in it.  We could
-     # do that instead in the top-level Makefile on a full uninstall,
-     # if we wanted.
      rm -rf $fndir
      ;;
   *) # The following will only apply with a custom install directory
@@ -22,15 +19,39 @@ case $fndir in
      # We now have a list of files, but we need to use `test -f' to check
      # (1) the glob got expanded (2) we are not looking at directories.
      for file in $allfuncs; do
-       if test -f $sdir_top/$file; then
-	 if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then
-	   file=`echo $file | sed -e 's%%^Functions/%'`
-	   rm -f $fndir/$file;
-	 else
-	   bfile="`echo $file | sed -e 's%^.*/%%'`"
-	   rm -f "$fndir/$bfile"; \
-	 fi
-       fi
+       case $file in
+       Scripts/*)
+	 ;;
+       *)
+         if test -f $sdir_top/$file; then
+	   if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then
+	     file=`echo $file | sed -e 's%%^(Functions|Completion)/%'`
+	     rm -f $fndir/$file
+	   else
+	     bfile="`echo $file | sed -e 's%^.*/%%'`"
+	     rm -f "$fndir/$bfile"
+	   fi
+         fi
+	 ;;
+       esac
+     done
+     ;;
+esac
+
+case $scriptdir in
+  *$VERSION*)
+     # $scriptdir might be the parent of fndir.
+     rm -rf $scriptdir
+     ;;
+  *) for file in $allfuncs; do
+	case $file in
+	Scripts/*)
+	  if test -f $sdir_top/$file; then
+	    bfile="`echo $file | sed -e 's%^.*/%%'`"
+	    rm -f "$scriptdir/$bfile"
+	  fi
+	  ;;
+	esac
      done
      ;;
 esac
diff --git a/Functions/Newuser/zsh-install-newuser b/Functions/Newuser/zsh-install-newuser
new file mode 100644
index 000000000..40bba720d
--- /dev/null
+++ b/Functions/Newuser/zsh-install-newuser
@@ -0,0 +1,11 @@
+# Function to install startup files for a new user.
+# This dummy version simply creates a new .zshrc with a comment.
+# FIXME: we don't want to distribute a file that does that, it
+# would be preferable to do nothing at all.
+
+# Sanitize environment.
+emulate -L zsh
+
+echo "# Created by newuser for $ZSH_VERSION" >${ZDOTDIR:-$HOME}/.zshrc
+
+unfunction zsh-install-newuser
diff --git a/Makefile.in b/Makefile.in
index 3521afa5e..75f951081 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -84,6 +84,7 @@ install.fns:
 	  test x$(sitefndir) != xno && \
 	    $(SHELL) $(sdir_top)/mkinstalldirs $(DESTDIR)$(sitefndir); \
 	  sdir_top="$(sdir_top)" fndir="$(fndir)" dir_top="$(dir_top)" \
+	  scriptdir="$(scriptdir)" \
 	  FUNCTIONS_SUBDIRS="$(FUNCTIONS_SUBDIRS)" \
 	  INSTALL_DATA="$(INSTALL_DATA)" \
 	  DESTDIR="$(DESTDIR)" VERSION="$(VERSION)" \
@@ -94,6 +95,7 @@ install.fns:
 uninstall.fns:
 	if test x$(fndir) != x && test x$(fndir) != xno; then \
 	  fndir="$(fndir)" dir_top="$(dir_top)" \
+	  scriptdir="$(scriptdir)" \
 	  FUNCTIONS_SUBDIRS="$(FUNCTIONS_SUBDIRS)" \
 	  DESTDIR="$(DESTDIR)" VERSION="$(VERSION)" \
 	  $(SHELL) $(sdir_top)/Config/uninstallfns.sh || exit 1; \
diff --git a/Scripts/newuser b/Scripts/newuser
new file mode 100644
index 000000000..47add8ed1
--- /dev/null
+++ b/Scripts/newuser
@@ -0,0 +1,6 @@
+# zsh script sourced at startup when a user is found to have
+# no startup files.  See the documentation for the zsh/newuser
+# module in zshmodules(1).
+
+autoload -U zsh-install-newuser
+zsh-install-newuser
diff --git a/Src/Modules/newuser.mdd b/Src/Modules/newuser.mdd
index 419511dc3..82a08a52e 100644
--- a/Src/Modules/newuser.mdd
+++ b/Src/Modules/newuser.mdd
@@ -1,8 +1,9 @@
 name=zsh/newuser
 link=dynamic
-# We will always try to load newuser, but there is
-# no error if it fails.
+# We will always try to load newuser, but there should
+# be no error if it fails, so don't use the standard mechanism.
 load=no
+functions='Scripts/newuser Functions/Newuser/*'
 
 objects="newuser.o"