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

Re: Typeset with array



On Fri, 19 Jun 2015 11:54:54 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> Does this raise a larger question of whether the reserved word should be
> enabled by default in "zsh mode"?

Yes, indeed.

> If this only affects the reserved word interface and the reserved word
> has to be explicitly enabled (by "emulate" or "enable") then there's no
> issue.
> 
> OTOH it would be nice to have the reserved word on by default.  Using
> array assignment syntax in the arguments of typeset would generally have
> been a syntax or globbing error in the past, so this word splitting is
> the primary place where a valid statement might change its semantics.

Right.  I'm assuming the ability to do

  local scalar=stuff array=(more stuff)

is so obviously natural we should find some way of enabling it by
default unless we hit some insuperable objection.

> } kludge in the old behaviour with NO_KSH_TYPESET if it seems desirable,
> 
> Are there any other practical differences between KSH_TYPESET and having
> the reserved word enabled?

Effectively, KSH_TYPESET was just a partial fix-up for the reserved word
behaviour, missing array handling, Actually, more than that, in bash at
least (I wouldn't be surprised if ksh was similar),

$ declare=declare
$ $declare foo=`echo bar one=two`
$ echo $one
two

which is NO_KSH_TYPESET behavioru --- so logically KSH_TYPESET should be
*off* from now on, but the reserved word scheme on, in emulation mode,
whatever happens in native mode.

> } though logically that shouldn't really control the reserved word
> } interface which should parse consistently.
> 
> Agreed.

I think there are two arguments around NO_KSH_TYPESET behaviour in
native mode (however arrived at):

1. We've always done it that way so should continue.

2. The only reason we left it that way by default is the fact that
KSH_TYPESET was only ever a partial fix that didn't parse assignments
properly.  With that objection removed there's no real reason for
NO_KSH_TYPESET; and further anyone relying on

   typeset foo=`echo one=two`

doing what it now does needs to get out more as it's an accident
waiting to happen.

I'm inclining to 2, but that may be because (as with the case parsing
change) I'm mssing some more widespread effect.  I'd vaguely guess that
anyone that didn't read the manual in some detail wouldn't be aware of
the current state of affairs.

The various other questions noted by you and Oliver are less fraught.

pws



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