Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: array prepend

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]



Note this is distinct from


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.

Messages sorted by: Reverse Date, Date, Thread, Author