1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-01 05:16:05 +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> 2005-07-20 Clint Adams <clint@zsh.org>
* 21499: Doc/Makefile.in: use newer texi2html syntax. * 21499: Doc/Makefile.in: use newer texi2html syntax.

View file

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
fndir=$DESTDIR$fndir fndir=$DESTDIR$fndir
scriptdir=$DESTDIR$scriptdir
/bin/sh $sdir_top/mkinstalldirs $fndir || exit 1; /bin/sh $sdir_top/mkinstalldirs $fndir || exit 1;
@ -25,13 +26,23 @@ for file in $allfuncs; do
Completion/*) Completion/*)
instdir="$fndir/Completion" instdir="$fndir/Completion"
;; ;;
Scripts/*)
instdir="$scriptdir"
;;
*) *)
subdir="`echo $file | sed -e 's%/[^/]*$%%' -e 's%^Functions/%%'`" subdir="`echo $file | sed -e 's%/[^/]*$%%' -e 's%^Functions/%%'`"
instdir="$fndir/$subdir" instdir="$fndir/$subdir"
;; ;;
esac esac
else else
instdir="$fndir" case "$file" in
Scripts/*)
instdir="$scriptdir"
;;
*)
instdir="$fndir"
;;
esac
fi fi
test -d $instdir || /bin/sh $sdir_top/mkinstalldirs $instdir || exit 1 test -d $instdir || /bin/sh $sdir_top/mkinstalldirs $instdir || exit 1
$INSTALL_DATA $sdir_top/$file $instdir || exit 1 $INSTALL_DATA $sdir_top/$file $instdir || exit 1

View file

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
fndir=$DESTDIR$fndir fndir=$DESTDIR$fndir
scriptdir=$DESTDIR$scriptdir
allfuncs="`grep ' functions=' ${dir_top}/config.modules | allfuncs="`grep ' functions=' ${dir_top}/config.modules |
sed -e '/^#/d' -e '/ link=no/d' -e 's/^.* functions=//'`" sed -e '/^#/d' -e '/ link=no/d' -e 's/^.* functions=//'`"
@ -10,10 +11,6 @@ allfuncs="`cd ${sdir_top}; echo ${allfuncs}`"
case $fndir in case $fndir in
*$VERSION*) *$VERSION*)
# Version specific function directory, safe to remove completely. # 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 rm -rf $fndir
;; ;;
*) # The following will only apply with a custom install directory *) # 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 # 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. # (1) the glob got expanded (2) we are not looking at directories.
for file in $allfuncs; do for file in $allfuncs; do
if test -f $sdir_top/$file; then case $file in
if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then Scripts/*)
file=`echo $file | sed -e 's%%^Functions/%'` ;;
rm -f $fndir/$file; *)
else if test -f $sdir_top/$file; then
bfile="`echo $file | sed -e 's%^.*/%%'`" if test x$FUNCTIONS_SUBDIRS != x -a x$FUNCTIONS_SUBDIRS != xno; then
rm -f "$fndir/$bfile"; \ file=`echo $file | sed -e 's%%^(Functions|Completion)/%'`
fi rm -f $fndir/$file
fi 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 done
;; ;;
esac 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 && \ test x$(sitefndir) != xno && \
$(SHELL) $(sdir_top)/mkinstalldirs $(DESTDIR)$(sitefndir); \ $(SHELL) $(sdir_top)/mkinstalldirs $(DESTDIR)$(sitefndir); \
sdir_top="$(sdir_top)" fndir="$(fndir)" dir_top="$(dir_top)" \ sdir_top="$(sdir_top)" fndir="$(fndir)" dir_top="$(dir_top)" \
scriptdir="$(scriptdir)" \
FUNCTIONS_SUBDIRS="$(FUNCTIONS_SUBDIRS)" \ FUNCTIONS_SUBDIRS="$(FUNCTIONS_SUBDIRS)" \
INSTALL_DATA="$(INSTALL_DATA)" \ INSTALL_DATA="$(INSTALL_DATA)" \
DESTDIR="$(DESTDIR)" VERSION="$(VERSION)" \ DESTDIR="$(DESTDIR)" VERSION="$(VERSION)" \
@ -94,6 +95,7 @@ install.fns:
uninstall.fns: uninstall.fns:
if test x$(fndir) != x && test x$(fndir) != xno; then \ if test x$(fndir) != x && test x$(fndir) != xno; then \
fndir="$(fndir)" dir_top="$(dir_top)" \ fndir="$(fndir)" dir_top="$(dir_top)" \
scriptdir="$(scriptdir)" \
FUNCTIONS_SUBDIRS="$(FUNCTIONS_SUBDIRS)" \ FUNCTIONS_SUBDIRS="$(FUNCTIONS_SUBDIRS)" \
DESTDIR="$(DESTDIR)" VERSION="$(VERSION)" \ DESTDIR="$(DESTDIR)" VERSION="$(VERSION)" \
$(SHELL) $(sdir_top)/Config/uninstallfns.sh || exit 1; \ $(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 name=zsh/newuser
link=dynamic link=dynamic
# We will always try to load newuser, but there is # We will always try to load newuser, but there should
# no error if it fails. # be no error if it fails, so don't use the standard mechanism.
load=no load=no
functions='Scripts/newuser Functions/Newuser/*'
objects="newuser.o" objects="newuser.o"