zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: array prepend
Date: Mon, 14 Jan 2013 07:32:36 -0800	[thread overview]
Message-ID: <130114073236.ZM6828@torch.brasslantern.com> (raw)
In-Reply-To: <CACQNQ9O5Te2xp8j2MjUsVN5gXQ9o2eySy=Baqj-t3htkKZgNKQ@mail.gmail.com>

On Jan 14, 10:18am, rahul wrote:
}
} I was wondering what the way for inserting into an array is. Is the
} following the simplest or most direct way:
} 
}     $FOO[1,2] xxx $FOO[3,-1]

Probably

	FOO[N]+=(xxx)

Note this is distinct from

	FOO[N]+=xxx

which will string-append xxx to the value stored at $FOO[N].

It'd be nice if this generalized to FOO[N-1]=(yyy) for prepend, but it
breaks at FOO[0] for backwards-compatibilty of $FOO[0] references and
also with the KSH_ARRAYS option where indexing is zero-based.  Also you
must take care with subtraction because of negative indices wrapping to
the end of the array.

} I'd also like to know what the vision for zsh is. Are there any major
} changes or enhancements coming up ? Is it to become more of a programming
} language or only seen as a glue language.

Well, neither really.  Zsh isn't a language, it's a shell.  It's meant
primarily to be used interactively; a lot of the features are present
only for the sake of making interactive use more powerful/customizable.

The language is closely tied to what's now standardized as the POSIX
shell language syntax and it's not going to stray too much farther from
that than it already has, if only because we're running out of syntax
that doesn't already have other semantics.

To the extent that POSIX shell language is a "glue language," that is
what zsh's language is likely to remain.

} I've been writing an app in zsh and totally loved the experience (as
} against previous experiences with bash). (However, the only thing that
} keeps biting me here and there are spaces in filenames for which I do
} use the @F notation. I only wish that behaviour would be a default
} since the syntax is very cumbersome)

Zsh's default behavior is to NOT split the string value of parameters
on spaces, so unless you set the SH_WORD_SPLIT option the need for @F
should be pretty small.  Of course it depends on what you're doing with
the file names, whether you're attempting to port a bash script, etc.


  reply	other threads:[~2013-01-14 15:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-11  6:58 sergio
2013-01-12  1:38 ` Oliver Kiddle
2013-01-13 18:51   ` Peter Stephenson
2013-01-14  4:48     ` rahul
2013-01-14 15:32       ` Bart Schaefer [this message]
2013-01-14 18:48         ` rahul
2013-01-17  4:34           ` Bart Schaefer

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=130114073236.ZM6828@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /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).