zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk
Subject: Re: PATCH: Re: Implementation of simple newuser module (how to start?)
Date: Wed, 20 Jul 2005 19:04:06 +0100	[thread overview]
Message-ID: <200507201804.j6KI474K004991@news01.csr.com> (raw)
In-Reply-To: <200507201401.j6KE1k5i004733@news01.csr.com>

Here's a basic newuser script to be installed and the outline of the
function that will be doing the work.  The function zsh-install-newuser
is the file to edit to do the work; everything else should work as it is.

We don't want to distribute the shell with this default version of
zsh-install-newuser, which will simply make it harder to fix things
later on; it would be better to have it do nothing.  However, I assume
it will be doing something by then.

I've created a separate Scripts directory for files which will be run
directly by the shell (actually sourced in this case) and adapted the
function installation system to install them.

Index: Makefile.in
===================================================================
RCS file: /cvsroot/zsh/zsh/Makefile.in,v
retrieving revision 1.13
diff -u -r1.13 Makefile.in
--- Makefile.in	3 Mar 2004 19:37:53 -0000	1.13
+++ Makefile.in	20 Jul 2005 17:59:57 -0000
@@ -84,6 +84,7 @@
 	  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 @@
 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; \
Index: Config/installfns.sh
===================================================================
RCS file: /cvsroot/zsh/zsh/Config/installfns.sh,v
retrieving revision 1.10
diff -u -r1.10 installfns.sh
--- Config/installfns.sh	13 Feb 2003 16:34:36 -0000	1.10
+++ Config/installfns.sh	20 Jul 2005 17:59:57 -0000
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 fndir=$DESTDIR$fndir
+scriptdir=$DESTDIR$scriptdir
 
 /bin/sh $sdir_top/mkinstalldirs $fndir || exit 1;
 
@@ -25,13 +26,23 @@
       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
Index: Config/uninstallfns.sh
===================================================================
RCS file: /cvsroot/zsh/zsh/Config/uninstallfns.sh,v
retrieving revision 1.3
diff -u -r1.3 uninstallfns.sh
--- Config/uninstallfns.sh	4 Dec 2000 19:21:07 -0000	1.3
+++ Config/uninstallfns.sh	20 Jul 2005 17:59:57 -0000
@@ -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 @@
 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 @@
      # 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
Index: Functions/Newuser/zsh-install-newuser
===================================================================
RCS file: Functions/Newuser/zsh-install-newuser
diff -N Functions/Newuser/zsh-install-newuser
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Functions/Newuser/zsh-install-newuser	20 Jul 2005 17:59:57 -0000
@@ -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
Index: Scripts/newuser
===================================================================
RCS file: Scripts/newuser
diff -N Scripts/newuser
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ Scripts/newuser	20 Jul 2005 17:59:57 -0000
@@ -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
Index: Src/Modules/newuser.mdd
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/newuser.mdd,v
retrieving revision 1.1
diff -u -r1.1 newuser.mdd
--- Src/Modules/newuser.mdd	20 Jul 2005 16:08:23 -0000	1.1
+++ Src/Modules/newuser.mdd	20 Jul 2005 17:59:57 -0000
@@ -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"
 
-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************


  reply	other threads:[~2005-07-20 18:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-17 20:16 Keir Mierle
2005-07-18 10:13 ` Peter Stephenson
2005-07-20 14:01 ` PATCH: " Peter Stephenson
2005-07-20 18:04   ` Peter Stephenson [this message]
2005-07-23  5:10     ` Bart Schaefer
2005-07-25  9:36       ` Peter Stephenson
2005-07-26 10:21         ` Peter Stephenson
2005-07-26 14:12           ` Bart Schaefer
2005-07-26 15:08             ` Peter Stephenson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200507201804.j6KI474K004991@news01.csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).