zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-workers@sunsite.dk
Subject: Re: parameter substitution used in _values
Date: Fri, 1 Jun 2001 15:01:58 +0000	[thread overview]
Message-ID: <1010601150158.ZM19978@candle.brasslantern.com> (raw)
In-Reply-To: <200106011339.PAA14041@beta.informatik.hu-berlin.de>

On Jun 1,  3:39pm, Sven Wischnowsky wrote:
} Subject: Re: parameter substitution used in _values
}
} The problem is that the positional parameters are internally turned into
} `$argv[n]'.

This is a bit strange on many levels:

zsh% noargv() { unset argv }
zsh% showargv() {
function> echo 1=$1 2=$2 @=\($@\) argv=\($argv\) $+argv
function> noargv
function> echo 1=$1 2=$2 @=\($@\) argv=\($argv\) $+argv
function> unset argv
function> echo 1=$1 2=$2 @=\($@\) argv=\($argv\) $+argv
function> }
zsh% showargv a b c d
1=a 2=b @=(a b c d) argv=(a b c d) 1
1=a 2=b @=(a b c d) argv=() 0
1= 2= @=() argv=() 0

So `unset argv' somehow did something with a param that was already unset.
Now run `showargv' a second time in the same shell:

zsh% showargv d c b a
1=d 2=c @=(d c b a) argv=() 0
1=d 2=c @=(d c b a) argv=() 0
1= 2= @=() argv=() 0

This is sort of documented:

argv <S> <Z>
     Same as *.  Assigning to argv changes the local positional
     parameters, but argv is *not* itself a local parameter.  Deleting
     argv with unset in any function deletes it everywhere, although
     only the innermost positional parameter array is deleted (so * and
     @ in other scopes are not affected).

It seems a bit odd that `unset argv' continues to have side effects after
argv has already been "deleted" but I guess that's just part of it being
<S>pecial.

-- 
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   


      parent reply	other threads:[~2001-06-01 15:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-01 13:14 Oliver Kiddle
2001-06-01 13:39 ` Sven Wischnowsky
2001-06-01 14:21   ` Oliver Kiddle
2001-06-01 15:01   ` Bart Schaefer [this message]

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=1010601150158.ZM19978@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=zsh-workers@sunsite.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).