1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-12-29 16:25:35 +01:00

21500: Add script and function as framework for new user stuff.

This commit is contained in:
Peter Stephenson 2005-07-20 18:08:39 +00:00
parent a4e534dcbc
commit 3d5bececac
7 changed files with 75 additions and 16 deletions

View file

@ -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.

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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; \

6
Scripts/newuser Normal file
View file

@ -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

View file

@ -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"