From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6120 invoked from network); 17 Sep 2001 16:14:59 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 17 Sep 2001 16:14:59 -0000 Received: (qmail 8030 invoked by alias); 17 Sep 2001 16:14:40 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 4233 Received: (qmail 8015 invoked from network); 17 Sep 2001 16:14:38 -0000 From: Bart Schaefer Message-Id: <1010917161307.ZM5925@candle.brasslantern.com> Date: Mon, 17 Sep 2001 16:13:07 +0000 In-Reply-To: <20010917112344.A3210@thelonious.new.ox.ac.uk> Comments: In reply to Adam Spiers "Re: retrieving invocation arguments" (Sep 17, 11:23am) References: <20010914214218.A23939@thelonious.new.ox.ac.uk> <1010915173427.ZM1780@candle.brasslantern.com> <20010917112344.A3210@thelonious.new.ox.ac.uk> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-users@sunsite.dk Subject: Re: retrieving invocation arguments MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 17, 11:23am, Adam Spiers wrote: } } Currently I have } } restart () { } exec $SHELL "$SHELL_ARGS" "$@" } } } } and I do } } export SHELL_ARGS="$@" } } in my ~/.switch_shell (run from bash). Ah. Well, "$@" doesn't include the option switches even in bash, and bash has the same behavior as zsh with respect to $0 and the first non- option argument following a -c command. Even if you did have the option switches, you couldn't use them if $SHELL had changed from the original shell. Also, "$SHELL_ARGS" is going to be one argument where the original "$@" may have had several. And I should repeat the warning about `export SHELL_ARGS="$@"' -- "$@" is an array with each element quoted, so what you've really written is export SHELL_ARGS="$1" "$2" "$3" ... which is probably not what you meant. Using "$@" works in bash because it treats the arguments to `export' as if they were assignment expressions; but in zsh that requires `setopt kshtypeset' (4.0.2 and later). Anyway, it's very difficult to restart the shell exactly as it was invoked unless you stash the arguments very early in .zshenv and have a cooperative /etc/zshenv. Probably the best thing would be along the lines of: restart_saveargs() { local x='(interactive|shinstdin|stdin)' local -a on off typeset -ga restart_args restart_options on=( ${(ok)options[(R)on]:#$~x} ) off=( ${(ok)options[(R)off]:#$~x}} ) restart_options=( ${on:+-o} ${(j.-o .)=on} ${off:++o} ${(j.+o .)=off} ) restart_args=( "$@" ) } restart() { emulate -L zsh if [[ $SHELL:t = zsh* ]]; then exec $SHELL $restart_options $restart_args else exec $SHELL $restart_args fi } restart_saveargs "$@" And now that's probably more glorious detail than I should have included. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net