zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Clint Olsen <olsenc@ichips.intel.com>
Cc: zsh-users@sunsite.auc.dk
Subject: Re: "exec zsh" inside .zprofile doesn't set SHELL
Date: Wed, 22 Sep 1999 08:57:17 +0000	[thread overview]
Message-ID: <990922085717.ZM16212@candle.brasslantern.com> (raw)
In-Reply-To: <19990922001426.B16998@ichips.intel.com>

On Sep 22, 12:14am, Clint Olsen wrote:
} Subject: Re: "exec zsh" inside .zprofile doesn't set SHELL
}
} I'm executing this in my .zprofile (nothing fancy).  So far, I've not had
} any problems with looping execs.  Apparently the results of "exec $SHELL"
} doesn't make it a login shell again.  Am I overlooking something?

That's right, "exec zsh" will not propagate login-shell-ness.  The best you
can do is "exec zsh -$-" which passes to the new zsh all the setopts of the
current one that can be represented as command-line flags.  That _will_
propagate login-ness, so then you need something like

    [[ "$ZSH_VERSION" = 3.0.5 ]] && export SHELL==zsh && exec $SHELL -$-

The problem with testing version numbers is that, whichever way you do the
equality (equal the old version or not-equal the new one), the wrong thing
may happen if one or the other gets upgraded.  And if for some reason the
output of =zsh is the path to the old version, you still have a loop.  So
IMO a better solution is

    export SHELL==zsh && export ZDOTDIR=$HOME/.myzsh && exec $SHELL -$-

The files in .myzsh can be links to the ones in $HOME (or in your regular
$ZDOTDIR if there is one) *except* for the one that contains the "exec",
so you can't possibly hit that more than once.

On a consulting job I did a while back the system zsh was version 2.4 (!!)
so I quickly compiled a 3.0.5 and set it up like this:

~/.zprofile contained:

    [[ -f ~/.myzsh/.zprofile ]] && source ~/.myzsh/.zprofile
    if ~/bin/zsh -fc 'exit 0'; then
	export SHELL=$HOME/bin/zsh
	export ZDOTDIR=$HOME/.myzsh
	exec $SHELL -$-
    fi

~/.myzsh/.zprofile didn't exist, that "source" was for completeness.

~/.zshenv and ~/.zlogin had a lot of skeleton setup stuff for my client's
local build environment, so left them alone.

~/.myzsh/.zshenv contained a "source ~/.zshenv" followed by some extra
setup stuff for 3.0.5.

~/.myzsh/.zlogin was the .zlogin that I cart around with me everywhere,
that handles every version of zsh from 2.0 through (then) 3.1.5 and makes
them act as much alike as possible, with "source ~/.zlogin" stuck in at a
strategic point.

~/.myzsh/.zlogout was a symlink to ~/.zlogout.

~/.zshrc was the version 2.4 initialization stuff.
~/.myzsh/.zshrc was my 3.0.5 initialization stuff.

Running zsh -fc in the "if" test was in case I logged in to a machine
that wasn't the same architecture as the one on which I built ~/bin/zsh;
they had a small number that were different, but I don't think I ever
actually used one.  Anyway, the end result was that I'd launch 3.0.5 but
duplicate reading only of the zshenv files, while falling through if my
homebuilt zsh didn't work for some reason.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


       reply	other threads:[~1999-09-22  9:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <19990921150657.A14612@ichips.intel.com>
     [not found] ` <990921223441.ZM15797@candle.brasslantern.com>
     [not found]   ` <19990921163747.A19650@ichips.intel.com>
     [not found]     ` <990922002045.ZM15869@candle.brasslantern.com>
     [not found]       ` <19990921173438.B37706@ichips.intel.com>
     [not found]         ` <990922051813.ZM15980@candle.brasslantern.com>
     [not found]           ` <19990922001426.B16998@ichips.intel.com>
1999-09-22  8:57             ` Bart Schaefer [this message]
1999-09-22 10:30               ` Zefram

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=990922085717.ZM16212@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=olsenc@ichips.intel.com \
    --cc=zsh-users@sunsite.auc.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).