zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: set -A
Date: Fri, 7 Feb 2003 03:53:14 +0000	[thread overview]
Message-ID: <1030207035314.ZM24755@candle.brasslantern.com> (raw)
In-Reply-To: <20030207000138.GK5418@msi.ld>

On Feb 6,  7:01pm, Paul Ackersviller wrote:
} Subject: set -A
}
} unset arr
} set -A arr "${arr[@]}" first
} [ ${#arr[@]} = 2 ] && echo "arr[0]='${arr[0]}' arr[1]='${arr[1]}'"
} 
} Note the null entry on the start of the array.

This really has nothing to do with "set -A".

If you've unset arr, then arr is not an array, and hence ${arr[@]} is
not an array either, and therefore "${arr[@]}" does not behave like
an array; rather, it behaves like a string, so putting it in double
quotes yields the empty string.

} I believe the above should work as in ksh, and consistently with
} positional parameters

Doesn't follow.  $@ cannot be unset, it can only be set to the empty
array.  This example ...

} set --
} set -A arr "$@" first
} echo arr now has only ${#arr[@]} element

... really corresponds to:

arr=()
set -A arr "${arr[@]}" first
echo arr now has only ${#arr[@]} element

} [...] it'd be nice if it at least worked like ksh in emulation mode.

This is a clash with zsh's usage where subscripts on a string yeild
substring slices.  The substring slice [@] is the entire string, so
${string[@]} == ${string}.  We were under the impression that this
could not possibly clash with a valid ksh script, because no working
ksh script could rely upon subscripting a string.

We may have to rethink that.


  reply	other threads:[~2003-02-07  3:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-07  0:01 Paul Ackersviller
2003-02-07  3:53 ` Bart Schaefer [this message]
2003-02-07 10:48   ` Peter Stephenson
2003-02-07 16:48     ` Bart Schaefer
2003-02-07 17:36       ` Peter Stephenson

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=1030207035314.ZM24755@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@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).