zsh-users
 help / color / mirror / code / Atom feed
* "${(s.:.)foo} and rc_expand_param
@ 2010-03-06 19:13 Frank Terbeck
  2010-03-06 22:08 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Frank Terbeck @ 2010-03-06 19:13 UTC (permalink / raw)
  To: zsh-users

Hey list,

Here is another thing I can't quite understand.

First, two excerpts from the manual:

  RC_EXPAND_PARAM (-P)
      Array expansions of the form ‘foo${xx}bar’, where the parameter xx
      is set to (a b c), are substituted with ‘fooabar foobbar foocbar’
      instead of the default ‘fooa b cbar’.
[...]

  s:string:
      Force field splitting at the separator string.  Note that a string
      of two or more characters means that all of them must match in
      sequence; this differs from the treatment of two or more
      characters in the IFS parameter.  See also the = flag and the
      SH_WORD_SPLIT option.

      For historical reasons, the usual behaviour that empty array
      elements are retained inside double quotes is disabled for arrays
      generated by splitting; hence the following:

             line="one::three"
             print -l "${(s.:.)line}"

      produces two lines of output for one and three and elides the
      empty field.  To override this behaviour, supply the "(@)" flag as
      well, i.e.  "${(@s.:.)line}".

Now, let's see what's happening:

zsh% foo="bar::baz"
zsh% print -l "${(s.:.)foo}"
bar
baz

Okay, this I expected, but now:

zsh% setopt rc_expand_param
zsh% print -l "${(s.:.)foo}"
bar

baz

This I did not; from the manual I'd expect to only see (@s.:.) pick up
the empty field in $foo.

Am I missing something here or is this a bug?

Regards, Frank

-- 
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
                                                  -- RFC 1925


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: "${(s.:.)foo} and rc_expand_param
  2010-03-06 19:13 "${(s.:.)foo} and rc_expand_param Frank Terbeck
@ 2010-03-06 22:08 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2010-03-06 22:08 UTC (permalink / raw)
  To: zsh-users

On Mar 6,  8:13pm, Frank Terbeck wrote:
} Subject: "${(s.:.)foo} and rc_expand_param
}
}   s:string:
}       For historical reasons, the usual behaviour that empty array
}       elements are retained inside double quotes is disabled for arrays
}       generated by splitting; hence the following:
} 
} zsh% setopt rc_expand_param
} zsh% print -l "${(s.:.)foo}"
} bar
} 
} baz
} 
} Am I missing something here or is this a bug?

I believe zsh is being faithful to the "rc" shell's behavior here.  The
doc note about "historical reasons" was added pretty recently, as was
the override of that behavor that's possible by using @s, so it's most
likely that there was always and intentionally this exception but that
it was missed when the doc was updated.

-- 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-03-06 22:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-06 19:13 "${(s.:.)foo} and rc_expand_param Frank Terbeck
2010-03-06 22:08 ` Bart Schaefer

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).