Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: retrieving invocation arguments
- X-seq: zsh-users 4237
- From: Adam Spiers <adam@xxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: retrieving invocation arguments
- Date: Tue, 18 Sep 2001 12:39:09 +0100
- In-reply-to: <1010917161307.ZM5925@xxxxxxxxxxxxxxxxxxxxxxx>; from schaefer@xxxxxxxxxxxxxxxx on Mon, Sep 17, 2001 at 04:13:07PM +0000
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20010914214218.A23939@xxxxxxxxxxxxxxxxxxxxxxx> <1010915173427.ZM1780@xxxxxxxxxxxxxxxxxxxxxxx> <20010917112344.A3210@xxxxxxxxxxxxxxxxxxxxxxx> <1010917161307.ZM5925@xxxxxxxxxxxxxxxxxxxxxxx>
- Reply-to: Adam Spiers <adam@xxxxxxxxxx>
Bart Schaefer (schaefer@xxxxxxxxxxxxxxxx) wrote:
> 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
That's OK, that "$@" refers to the arguments passed to .switch_shell,
which are hard-coded in my .bashrc rather than being those bash was
invoked with.
> 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).
Yes, I was aware of that problem, although I guess what I actually
meant to write was
export SHELL_ARGS="$*"
which should be a bit better, but still not ideal. Anyhow,
dissatisfaction with this whole approach was the main reason for
asking the original question.
> 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.
I don't (and won't) have a cooperative /etc/zshenv, which is why it
would be nice if zsh itself made the information easily retrievable,
if it wouldn't be hard to implement cleanly.
> And now that's probably more glorious detail than I should have included.
:-)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author