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

PATCH: Re: adding a toplevel zsh.spec.in file



Adam Spiers wrote:
>In /etc/zshenv:
>
>  export USER=`id -un`
>  export LOGNAME=$USER
>  export HOSTNAME=$HOST
>  
>  # this only on appropriate boxes of course
>  export MAIL=/var/spool/mail/$USER

These, if they exist at all (which is OK if done right), should be in
/etc/zprofile, and duplicated in /etc/profile.  They should be set
on *login*, not for every shell I start -- if I want to set MAIL to
somewhere different, that setting should propagate to any subshells I run.

>  HISTSIZE=1000
>  HISTFILE=~/.zshhistory
>  SAVEHIST=1000

No way.  zsh has a perfectly well-established default behaviour
w.r.t. history saving, and if I don't override it I should get zsh's
default, not whatever some RPM builder thought might be nice.

>  export INPUTRC=/etc/inputrc

My environment is my own.  /etc{z,}profile can justly set MAIL and a
few others -- this is just letting the user's shell know what it needs
to know about the local system.  INPUTRC is entirely an individual's
decision, and should be left strictly to the individual.

>Now here's a candidate for StartupFiles/RedHat/zshrc.  Anything badly
>wrong?
...
># Set up aliases
>alias mv='nocorrect mv'       # no spelling correction on mv
>alias cp='nocorrect cp'       # no spelling correction on cp
>alias mkdir='nocorrect mkdir' # no spelling correction on mkdir

Evil.  mv, cp and mkdir should not be aliases by default; zsh is well
established in starting up without any aliases by default.  As before,
don't change zsh's default; a user that wants to achieve a particular
effect with zsh is forced to check this sort of startup file to see which
desired zsh defaults get broken and need to be restated explicitly in
the personal startup file.

># Where to look for autoloaded function definitions
>fpath=(
>       ~/{lib/zsh,.zsh}/{functions,scripts}(N)
>       ~/.z{sh,}func*(N)
>       $fpath
>       /usr/doc/zsh*/Functions(N)
>      )
>
>typeset -U fpath

zsh has a perfectly sensible default.  You're adding to the fpath a
bunch of directories that the user may or may not want in their fpath,
making an assumption that is not always correct, to achieve a convenience
that the user can't rely on.

># Autoload all shell functions from all directories
># in $fpath that have the executable bit on
># (the executable bit is not necessary, but gives
># you an easy way to stop the autoloading of a
># particular shell function).
>for dirname in $fpath
>do
>  fns=( $dirname/*(N.x:t) )
>  (( $#fns )) && autoload $fns
>done

It's a neat trick, if someone wants to do that.  Personally I don't like
to handle my fpath that way, and I suspect that most people don't really
want those execute bit semantics.  Don't stuff it down people's throats.

>PS1='%n@%m %B%3~%b %# '        # default prompt

Just don't.  As before, you're overriding a perfectly reasonable
default and imposing your arbitrary tastes on people.  In addition,
there's a particular problem with PS1, when it gets exported, that it
affects other shells that get called that have a different PS1 syntax.
(This is particularly visible, for example, when execing zsh from /bin/sh
on a stock Red Hat.)

Hmm, that doesn't leave anything for /etc/zshrc or /etc/zshenv, and I
can't see any valid reason for either of those files to be non-empty.
Similarly /etc/zlogin, for that matter, and I think that /etc/zprofile
should only mirror the contents of /etc/profile.

So here's my recomendation for zsh RPM builders: ship no /etc/zshrc,
/etc/zshenv, /etc/zlogin or /etc/zlogout, and have /etc/zprofile
be a symbolic link -> profile.  (This still leaves a broken Red Hat
/etc/profile, but that's outside the scope of a zsh package.)  If you want
to have fancy example startup files, go ahead and put them in /etc/skel --
that's what it's there for.

And my suggestion for zsh-workers: let's get rid of /etc/z*.  They're just
confusing things.  /etc/profile is useful, the rest are just invitations
to tread on users' toes.  So let's have zsh process /etc/profile first
thing (but only in a login shell), and not look at anything else in /etc.
I suggest a configure option to support the current set of files, for
those few people that really do need them.  In fact, configure already
has the right options, we just need to change their behaviour a bit.

The only annoying thing left is that the global zprofile is run *after*
the user's .zshenv.  This really ought to be the other way round, to
match the usage of /etc/profile.  It seems that a distinction must be
made between profile and zprofile.

The patch below is NOT committed due to anticipated controversy
-- I'd like to see a consensus on this before implementing such a
significant change in default behaviour.  It would implement what I
suggest above: all global rc files are disabled by default (enableable
with --enable-z{profile,sh{env,rc},log{in,out}}=PATH), and /etc/profile
used by default instead (disableable with --disable-profile).  There are
consequent documentation changes.

-zefram

Index: configure.in
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.in,v
retrieving revision 1.12
diff -c -r1.12 configure.in
*** configure.in	2000/07/07 17:12:17	1.12
--- configure.in	2000/07/18 01:50:18
***************
*** 113,123 ****
  AC_ARG_ENABLE(zshenv,
  [  --enable-zshenv=pathname   the full pathname of the global zshenv script],
  [zshenv="$enableval"],
! [if test "x$etcdir" = xno; then
!   zshenv=no
! else
!   zshenv="$etcdir/zshenv"
! fi])
  if test "x$zshenv" != xno; then
    AC_DEFINE_UNQUOTED(GLOBAL_ZSHENV, "$zshenv")
  fi
--- 113,119 ----
  AC_ARG_ENABLE(zshenv,
  [  --enable-zshenv=pathname   the full pathname of the global zshenv script],
  [zshenv="$enableval"],
! [zshenv=no])
  if test "x$zshenv" != xno; then
    AC_DEFINE_UNQUOTED(GLOBAL_ZSHENV, "$zshenv")
  fi
***************
*** 126,136 ****
  AC_ARG_ENABLE(zshrc,
  [  --enable-zshrc=pathname    the full pathname of the global zshrc script],
  [zshrc="$enableval"],
! [if test "x$etcdir" = xno; then
!   zshrc=no
! else
!   zshrc="$etcdir/zshrc"
! fi])
  if test "x$zshrc" != xno; then
    AC_DEFINE_UNQUOTED(GLOBAL_ZSHRC, "$zshrc")
  fi
--- 122,128 ----
  AC_ARG_ENABLE(zshrc,
  [  --enable-zshrc=pathname    the full pathname of the global zshrc script],
  [zshrc="$enableval"],
! [zshrc=no])
  if test "x$zshrc" != xno; then
    AC_DEFINE_UNQUOTED(GLOBAL_ZSHRC, "$zshrc")
  fi
***************
*** 139,149 ****
  AC_ARG_ENABLE(zprofile,
  [  --enable-zprofile=pathname the full pathname of the global zprofile script],
  [zprofile="$enableval"],
! [if test "x$etcdir" = xno; then
!   zprofile=no
! else
!   zprofile="$etcdir/zprofile"
! fi])
  if test "x$zprofile" != xno; then
    AC_DEFINE_UNQUOTED(GLOBAL_ZPROFILE, "$zprofile")
  fi
--- 131,137 ----
  AC_ARG_ENABLE(zprofile,
  [  --enable-zprofile=pathname the full pathname of the global zprofile script],
  [zprofile="$enableval"],
! [zprofile=no])
  if test "x$zprofile" != xno; then
    AC_DEFINE_UNQUOTED(GLOBAL_ZPROFILE, "$zprofile")
  fi
***************
*** 152,162 ****
  AC_ARG_ENABLE(zlogin,
  [  --enable-zlogin=pathname   the full pathname of the global zlogin script],
  [zlogin="$enableval"],
! [if test "x$etcdir" = xno; then
!   zlogin=no
! else
!   zlogin="$etcdir/zlogin"
! fi])
  if test "x$zlogin" != xno; then
    AC_DEFINE_UNQUOTED(GLOBAL_ZLOGIN, "$zlogin")
  fi
--- 140,146 ----
  AC_ARG_ENABLE(zlogin,
  [  --enable-zlogin=pathname   the full pathname of the global zlogin script],
  [zlogin="$enableval"],
! [zlogin=no])
  if test "x$zlogin" != xno; then
    AC_DEFINE_UNQUOTED(GLOBAL_ZLOGIN, "$zlogin")
  fi
***************
*** 165,184 ****
  AC_ARG_ENABLE(zlogout,
  [  --enable-zlogout=pathname  the full pathname of the global zlogout script],
  [zlogout="$enableval"],
! [if test "x$etcdir" = xno; then
!   zlogout=no
! else
!   zlogout="$etcdir/zlogout"
! fi])
  if test "x$zlogout" != xno; then
    AC_DEFINE_UNQUOTED(GLOBAL_ZLOGOUT, "$zlogout")
  fi
  
  AC_SUBST(zshenv)dnl
  AC_SUBST(zshrc)dnl
  AC_SUBST(zprofile)dnl
  AC_SUBST(zlogin)dnl
  AC_SUBST(zlogout)dnl
  
  dnl Do you want dynamically loaded binary modules.
  undefine([dynamic])dnl
--- 149,174 ----
  AC_ARG_ENABLE(zlogout,
  [  --enable-zlogout=pathname  the full pathname of the global zlogout script],
  [zlogout="$enableval"],
! [zlogout=no])
  if test "x$zlogout" != xno; then
    AC_DEFINE_UNQUOTED(GLOBAL_ZLOGOUT, "$zlogout")
  fi
  
+ undefine([profile])dnl
+ AC_ARG_ENABLE(profile,
+ [  --enable-profile=pathname  the full pathname of the global profile script],
+ [profile="$enableval"],
+ [profile=/etc/profile])
+ if test "x$profile" != xno; then
+   AC_DEFINE_UNQUOTED(GLOBAL_PROFILE, "$profile")
+ fi
+ 
  AC_SUBST(zshenv)dnl
  AC_SUBST(zshrc)dnl
  AC_SUBST(zprofile)dnl
  AC_SUBST(zlogin)dnl
  AC_SUBST(zlogout)dnl
+ AC_SUBST(profile)dnl
  
  dnl Do you want dynamically loaded binary modules.
  undefine([dynamic])dnl
Index: Src/init.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/init.c,v
retrieving revision 1.6
diff -c -r1.6 init.c
*** Src/init.c	2000/07/13 17:06:19	1.6
--- Src/init.c	2000/07/18 01:50:25
***************
*** 831,836 ****
--- 831,840 ----
  	} else
  	    source("/etc/suid_profile");
      } else {
+ #ifdef GLOBAL_PROFILE
+ 	if (islogin)
+ 	    source(GLOBAL_PROFILE);
+ #endif
  #ifdef GLOBAL_ZSHENV
  	source(GLOBAL_ZSHENV);
  #endif
Index: acconfig.h
===================================================================
RCS file: /cvsroot/zsh/zsh/acconfig.h,v
retrieving revision 1.4
diff -c -r1.4 acconfig.h
*** acconfig.h	2000/07/04 08:44:03	1.4
--- acconfig.h	2000/07/18 01:50:00
***************
*** 31,51 ****
  /***** shouldn't have to change anything below here *****/
  @TOP@
  
! /* The global file to source absolutely first whenever zsh is run; *
!  * if undefined, don't source anything                             */
! #undef GLOBAL_ZSHENV
  
  /* The global file to source whenever zsh is run; *
   * if undefined, don't source anything            */
! #undef GLOBAL_ZSHRC
! 
! /* The global file to source whenever zsh is run as a login shell; *
!  * if undefined, don't source anything                             */
! #undef GLOBAL_ZLOGIN
  
  /* The global file to source whenever zsh is run as a login shell, *
   * before zshrc is read; if undefined, don't source anything       */
  #undef GLOBAL_ZPROFILE
  
  /* The global file to source whenever zsh was run as a login shell.  *
   * This is sourced right before exiting.  If undefined, don't source *
--- 31,55 ----
  /***** shouldn't have to change anything below here *****/
  @TOP@
  
! /* The global file to source first whenever zsh is run as a login shell, *
!  * before anything else is read; if undefined, don't source anything     */
! #undef GLOBAL_PROFILE
  
  /* The global file to source whenever zsh is run; *
   * if undefined, don't source anything            */
! #undef GLOBAL_ZSHENV
  
  /* The global file to source whenever zsh is run as a login shell, *
   * before zshrc is read; if undefined, don't source anything       */
  #undef GLOBAL_ZPROFILE
+ 
+ /* The global file to source whenever zsh is run interactively; *
+  * if undefined, don't source anything                          */
+ #undef GLOBAL_ZSHRC
+ 
+ /* The global file to source whenever zsh is run as a login shell, *
+  * after zshrc is read; if undefined, don't source anything        */
+ #undef GLOBAL_ZLOGIN
  
  /* The global file to source whenever zsh was run as a login shell.  *
   * This is sourced right before exiting.  If undefined, don't source *
Index: INSTALL
===================================================================
RCS file: /cvsroot/zsh/zsh/INSTALL,v
retrieving revision 1.1.1.21
diff -c -r1.1.1.21 INSTALL
*** INSTALL	2000/03/01 18:31:21	1.1.1.21
--- INSTALL	2000/07/18 01:49:59
***************
*** 246,264 ****
  Startup/shutdown files
  ----------------------
  
! Zsh has several startup/shutdown files which are in /etc by default.  This
! can be overriden using one of the options below when invoking "configure".
  
-  --enable-etcdir=directory    # default directory for global zsh scripts
   --enable-zshenv=pathname     # the full pathname of the global zshenv script
   --enable-zshrc=pathname      # the full pathname of the global zshrc script
   --enable-zlogin=pathname     # the full pathname of the global zlogin script
   --enable-zprofile=pathname   # the full pathname of the global zprofile script
   --enable-zlogout=pathname    # the full pathname of the global zlogout script
  
! Any startup/shutdown script can be disabled by giving the
! --disable-scriptname option to "configure".  The --disable-etcdir option
! disables all startup/shutdown files which are not explicitely enabled.
  
  Shell functions
  ---------------
--- 246,268 ----
  Startup/shutdown files
  ----------------------
  
! Global versions of zsh's startup/shutdown files can be configured.  These
! are each run just before the corresponding personal startup file (just
! after in the case of zlogout).  By default, none of these is enabled.
! This can be overriden using the options below when invoking "configure".
  
   --enable-zshenv=pathname     # the full pathname of the global zshenv script
   --enable-zshrc=pathname      # the full pathname of the global zshrc script
   --enable-zlogin=pathname     # the full pathname of the global zlogin script
   --enable-zprofile=pathname   # the full pathname of the global zprofile script
   --enable-zlogout=pathname    # the full pathname of the global zlogout script
  
! Additionally, the pathname of the global profile file can be configured:
! 
!  --enable-profile=pathname    # the full pathname of the global profile script
! 
! This defaults to /etc/profile.  The profile script can be disabled by
! giving the --disable-profile option to "configure".
  
  Shell functions
  ---------------
Index: Doc/Zsh/filelist.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/filelist.yo,v
retrieving revision 1.2
diff -c -r1.2 filelist.yo
*** Doc/Zsh/filelist.yo	2000/04/01 20:43:44	1.2
--- Doc/Zsh/filelist.yo	2000/07/18 01:50:19
***************
*** 7,15 ****
  list(tt($ZDOTDIR/.zlogin))
  list(tt($ZDOTDIR/.zlogout))
  list(tt(${TMPPREFIX}*)   (default is /tmp/zsh*))
! list(tt(/etc/zshenv))
! list(tt(/etc/zprofile))
! list(tt(/etc/zshrc))
! list(tt(/etc/zlogin))
! list(tt(/etc/zlogout)    (installation-specific - tt(/etc) is the default))
  endlist()
--- 7,11 ----
  list(tt($ZDOTDIR/.zlogin))
  list(tt($ZDOTDIR/.zlogout))
  list(tt(${TMPPREFIX}*)   (default is /tmp/zsh*))
! list(tt(/etc/profile))
  endlist()
Index: Doc/Zsh/files.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/files.yo,v
retrieving revision 1.2
diff -c -r1.2 files.yo
*** Doc/Zsh/files.yo	2000/04/01 20:43:44	1.2
--- Doc/Zsh/files.yo	2000/07/18 01:50:19
***************
*** 7,13 ****
  cindex(shutdown files)
  pindex(NO_RCS, use of)
  pindex(NO_GLOBAL_RCS, use of)
! Commands are first read from tt(/etc/zshenv); this cannot be overridden.
  Subsequent behaviour is modified by the tt(RCS) and
  tt(GLOBAL_RCS) options; the former affects all startup files, while the
  second only affects those in the tt(/etc) directory.  If one of the options
--- 7,17 ----
  cindex(shutdown files)
  pindex(NO_RCS, use of)
  pindex(NO_GLOBAL_RCS, use of)
! First, if the shell is a login shell,
! commands are read from the global profile file (by default tt(/etc/profile)).
! Commands are then read from the global zshenv file
! (if one is configured, which it is not by default);
! this cannot be overridden.
  Subsequent behaviour is modified by the tt(RCS) and
  tt(GLOBAL_RCS) options; the former affects all startup files, while the
  second only affects those in the tt(/etc) directory.  If one of the options
***************
*** 19,32 ****
  Commands are then read from tt($ZDOTDIR/.zshenv).
  pindex(LOGIN, use of)
  If the shell is a login shell, commands
! are read from tt(/etc/zprofile) and then tt($ZDOTDIR/.zprofile).
  Then, if the shell is interactive,
! commands are read from tt(/etc/zshrc) and then tt($ZDOTDIR/.zshrc).
! Finally, if the shell is a login shell, tt(/etc/zlogin) and
! tt($ZDOTDIR/.zlogin) are read.
  
  When a login shell exits, the files tt($ZDOTDIR/.zlogout) and then
! tt(/etc/zlogout) are read.  This happens with either an explicit exit
  via the tt(exit) or tt(logout) commands, or an implicit exit by reading
  end-of-file from the terminal.  However, if the shell terminates due
  to tt(exec)'ing another process, the logout files are not read.
--- 23,43 ----
  Commands are then read from tt($ZDOTDIR/.zshenv).
  pindex(LOGIN, use of)
  If the shell is a login shell, commands
! are read from the global zprofile file
! (if one is configured, which it is not by default),
! and then tt($ZDOTDIR/.zprofile).
  Then, if the shell is interactive,
! commands are read from the global zshrc file
! (if one is configured, which it is not by default),
! and then tt($ZDOTDIR/.zshrc).
! Finally, if the shell is a login shell,
! commands are read from the global zlogin file
! (if one is configured, which it is not by default),
! and then tt($ZDOTDIR/.zlogin).
  
  When a login shell exits, the files tt($ZDOTDIR/.zlogout) and then
! the global zlogout file (if one is configured, which it is not by default)
! are read.  This happens with either an explicit exit
  via the tt(exit) or tt(logout) commands, or an implicit exit by reading
  end-of-file from the terminal.  However, if the shell terminates due
  to tt(exec)'ing another process, the logout files are not read.
***************
*** 36,45 ****
  saved.
  
  If tt(ZDOTDIR) is unset, tt(HOME) is used instead.
- Those files listed above as being in tt(/etc) may be in another
- directory, depending on the installation.
  
! As tt(/etc/zshenv) is run for all instances of zsh, it is important that
  it be kept as small as possible.  In particular, it is a good idea to
  put code that does not need to be run for every single shell behind
  a test of the form `tt(if [[ -o rcs ]]; then ...)' so that it will not
--- 47,54 ----
  saved.
  
  If tt(ZDOTDIR) is unset, tt(HOME) is used instead.
  
! As the global zshenv file is run for all instances of zsh, it is important that
  it be kept as small as possible.  In particular, it is a good idea to
  put code that does not need to be run for every single shell behind
  a test of the form `tt(if [[ -o rcs ]]; then ...)' so that it will not
Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.9
diff -c -r1.9 options.yo
*** Doc/Zsh/options.yo	2000/07/03 08:48:23	1.9
--- Doc/Zsh/options.yo	2000/07/18 01:50:25
***************
*** 415,424 ****
  cindex(startup files, global, inhibiting)
  cindex(files, global startup, inhibiting)
  item(tt(GLOBAL_RCS) (tt(-d)) <D>)(
! If this option is unset, the startup files tt(/etc/zprofile),
! tt(/etc/zshrc), tt(/etc/zlogin) and tt(/etc/zlogout) will not be run.  It
  can be disabled and re-enabled at any time, including inside local startup
  files (tt(.zshrc), etc.).
  )
  pindex(GLOB_ASSIGN)
  item(tt(GLOB_ASSIGN) <C>)(
--- 415,424 ----
  cindex(startup files, global, inhibiting)
  cindex(files, global startup, inhibiting)
  item(tt(GLOBAL_RCS) (tt(-d)) <D>)(
! If this option is unset, the global startup files will not be run.  It
  can be disabled and re-enabled at any time, including inside local startup
  files (tt(.zshrc), etc.).
+ It does not affect use of the global profile and zshenv.
  )
  pindex(GLOB_ASSIGN)
  item(tt(GLOB_ASSIGN) <C>)(
***************
*** 930,940 ****
  pindex(RCS)
  cindex(startup files, sourcing)
  item(tt(RCS) (tt(PLUS()f)) <D>)(
! After tt(/etc/zshenv) is sourced on startup, source the
! tt(.zshenv), tt(/etc/zprofile), tt(.zprofile),
! tt(/etc/zshrc), tt(.zshrc), tt(/etc/zlogin), tt(.zlogin), and tt(.zlogout)
! files, as described in noderef(Files).
! If this option is unset, the tt(/etc/zshenv) file is still sourced, but any
  of the others will not be; it can be set at any time to prevent the
  remaining startup files after the currently executing one from
  being sourced.
--- 930,942 ----
  pindex(RCS)
  cindex(startup files, sourcing)
  item(tt(RCS) (tt(PLUS()f)) <D>)(
! After the global zshenv is sourced on startup, source the
! tt(.zshenv), the global zprofile, tt(.zprofile),
! the global zshrc, tt(.zshrc), the global zlogin, tt(.zlogin),
! tt(.zlogout) and the global zlogout,
! as described in noderef(Files).
! If this option is unset,
! the global profile and zshenv are still sourced, but any
  of the others will not be; it can be set at any time to prevent the
  remaining startup files after the currently executing one from
  being sourced.
END



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