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

Some comments on Mandrake zsh RPMs



Actually, this can all be summed up in one comment:

Just because zsh provides for /etc/z{shenv,profile,shrc,login,logout}
doesn't mean they should all be non-empty.  In fact, they shouldn't be
there at all unless there's a *very* good reason for them to be.

Let's talk about a few of the things that are present in Mandrake's
/etc/z* files.

In /etc/zshenv, which at least has some reason to exist:

 if [ `id -u` -eq 0 ]; then
   path=(/sbin /usr/sbin)
 fi

This is something copied from RedHat.  The best thing about it is that it
helped me find a race condition in backtick evaluation, about a year ago.
It would be much better written:

 if (( EUID == 0 )); then

Following that, there's:

 echo $PATH | /bin/grep -q "\W$X11HOME/bin:" || path=($path $X11HOME/bin)
 echo $PATH | /bin/grep -q "\W/bin:" || path=($path /bin)

And so on.  All those pipes and greps are just cruft.  All that's needed:

 typeset -U path
 path=($path $X11HOME/bin /bin /usr/bin /usr/local/bin)

In /etc/zprofile is this:

 if [[ $(id -gn) = $(id -un) && $(id -u) -gt 14 ]]; then
         umask 002
 else
         umask 022
 fi

This is actually repeated verbatim in /etc/zshrc, which is the better
place for it; all interactive shells read zshrc, but only login shells
read zprofile.  Wherever it's put, only one of those $(id ...) is
necessary:

 if [[ $(id -gn) = $USERNAME && $EUID -gt 14 ]]; then

Next is /etc/zshrc, which is pretty bad.

If it's really necessary to source /etc/profile.d/*.sh, of which I am not
convinced, at least it might be wise to do it in /etc/zprofile rather than
in /etc/zshrc.  RedHat has it in zprofile, but thankfully commented out.

Then there's this:

 export USER=$(id -un)
 export LOGNAME=$USER
 export HOSTNAME=$(/bin/hostname)

LOGNAME is set automatically by zsh.  So are USERNAME and HOST.  If it's
really necessary to have USER and HOSTNAME, use:

 export USER=$USERNAME
 export HOSTNAME=$HOST

Next is:

 path=($path $HOME/bin)
 export PATH=$PATH:$HOME/bin

After all that extra work in zshenv to avoid adding the same directory to
the path multiple times, here $HOME/bin is added twice!  $PATH is
automatically kept in sync when $path is assigned, and is exported by
default.  Drop the "export" line.

One last specific suggestion:

 zmodload | grep -q complist || zmodload complist

is better expressed as

 zmodload -ui complist

where the -i option for "ignore" causes it to be silent if the module
is already loaded.  In -dev-16 and later, it's more correct to use

 zmodload -ui zsh/complist

because the naming convention has changed.

Now some general griping:

I won't comment specifically on all the aliases except to say that I don't
think they should be there.  Particularly "alias -g" can badly confuse an
unsuspecting user; how do YOU know that I never create a file named "G" or
"L" or "O"?

The bindkey for magic-space is another RedHat gratuity.  It's not strictly
wrong for it to be there, but the behavior can be annoying to a fast
typist.  It's particularly bad if you're attempting to embed a space in
a history reference.

I also find the large collection of setopts to be gratuitous.  Why turn
off completeinword?  (It's off by default, so the only possible reason is
to override a user setting; ick.)  Isn't interactivecomments potentially
confusing?  And the best reasons I can think of for setting kshglob,
posixbuiltins, and rcexpandparam are to parse /etc/profile.d/* correctly
(in which case ksharrays might also be needed); but the setopts come much
too late for that.  I'd prefer they weren't there at all.

I'm curious, what users did you have in mind when making these choices?

OK, enough griping.  You have a chance here to take yet another thing that
RedHat botched and improve on it; please do, rather than making it worse.
Thanks for listening.

-- 
Bart Schaefer
Maintainer, zsh 3.0 series



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