zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ibmth.df.unipi.it>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: zsh-3.1.5-pws-7: "$a[@]" with $a unset
Date: Fri, 12 Feb 1999 10:28:58 +0100	[thread overview]
Message-ID: <9902120928.AA34074@ibmth.df.unipi.it> (raw)
In-Reply-To: "Sven Wischnowsky"'s message of "Fri, 12 Feb 1999 09:53:59 NFT." <199902120853.JAA08542@beta.informatik.hu-berlin.de>

Sven Wischnowsky wrote:
>   % foo() { echo $# }
>   % unset a
>   % foo $a[@]
>   0                    # fine
>   % foo "$a[@]"
>   1                    # oops

The code's a little murky (as in `hell is murky' --- or'ing with
something is a pretty shoddy way of making a value negative,
particularly when the SCANPM_ISVAR_AT flag is never seen again), but
the following seems to do the trick.  Note that putting `a=()' before
would have been a workaround.

> The same for `$a[*]' and `$a'.

That's right, surely?  Quoted variables only expand to nothing if the
@ is present.

--- Src/params.c.isarr	Mon Feb  1 09:52:30 1999
+++ Src/params.c	Fri Feb 12 10:14:14 1999
@@ -966,7 +966,7 @@
     if (*tbrack == Outbrack)
 	*tbrack = ']';
     if ((s[0] == '*' || s[0] == '@') && s[1] == ']') {
-	if (v->isarr && s[0] == '@')
+	if ((v->isarr || !v->pm || !*v->pm->nam) && s[0] == '@')
 	    v->isarr |= SCANPM_ISVAR_AT;
 	v->a = 0;
 	v->b = -1;

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


  reply	other threads:[~1999-02-12  9:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-12  8:53 Tar file and Re: Bad interaction between -iprefix and -string Sven Wischnowsky
1999-02-12  9:28 ` Peter Stephenson [this message]
1999-02-12 15:43   ` PATCH: zsh-3.1.5-pws-7: "$a[@]" with $a unset Bart Schaefer
1999-02-12 15:45     ` Peter Stephenson
1999-02-12 17:33       ` Bart Schaefer
1999-02-13  7:05         ` PATCH: " Bart Schaefer
1999-02-12  9:48 Sven Wischnowsky

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=9902120928.AA34074@ibmth.df.unipi.it \
    --to=pws@ibmth.df.unipi.it \
    --cc=zsh-workers@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).