zsh-users
 help / color / mirror / code / Atom feed
* z flag in parameter expansion doesn't use $IFS ?
@ 2012-10-18 22:18 Han Pingtian
  2012-10-19  8:26 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: Han Pingtian @ 2012-10-18 22:18 UTC (permalink / raw)
  To: zsh-user

Hello, 

It looks like the z flag of parameter expansion doesn't care what the
value of IFS is:

% zsh -c 'var="foo ''bar baz''";print -l ${(z)var}'
foo
'bar baz'
% zsh -c 'IFS=:;var="foo:''bar:baz''";print -l ${=var}'
foo
'bar
baz'
% zsh -c 'IFS=:;var="foo:''bar:baz''";print -l ${(z)var}'
foo:'bar:baz'
%

I believe z flag should regard IFS and split expansion results just like
the shell parsing. Or I'm missing something here? Please help.

Thanks in advance.


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

* Re: z flag in parameter expansion doesn't use $IFS ?
  2012-10-18 22:18 z flag in parameter expansion doesn't use $IFS ? Han Pingtian
@ 2012-10-19  8:26 ` Peter Stephenson
  2012-10-19  8:53   ` Han Pingtian
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2012-10-19  8:26 UTC (permalink / raw)
  To: zsh-user

On Fri, 19 Oct 2012 06:18:26 +0800
Han Pingtian <hanpt@linux.vnet.ibm.com> wrote:
> It looks like the z flag of parameter expansion doesn't care what the
> value of IFS is:

Yes, this is correct.  It's using the shell grammar for this.  If you
type "echo foo", it doesn't matter what IFS is, it will always treat
that as two words with space as separator.  The other splitting flags
use IFS.

> I just found that it looks like the z flag won't cause "forced joining"
> which stated in rules 10, like this:

Yes, (z) is not like the other splitting flags.  It's a utility for when you
need something that obeys shell parsing rules.  It's not a simple
word-splitting tool, which is what the other splitting flags are for.

pws


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

* Re: z flag in parameter expansion doesn't use $IFS ?
  2012-10-19  8:26 ` Peter Stephenson
@ 2012-10-19  8:53   ` Han Pingtian
  0 siblings, 0 replies; 3+ messages in thread
From: Han Pingtian @ 2012-10-19  8:53 UTC (permalink / raw)
  To: zsh-users

On Fri, Oct 19, 2012 at 09:26:22AM +0100, Peter Stephenson wrote:
> On Fri, 19 Oct 2012 06:18:26 +0800
> Han Pingtian <hanpt@linux.vnet.ibm.com> wrote:
> > It looks like the z flag of parameter expansion doesn't care what the
> > value of IFS is:
> 
> Yes, this is correct.  It's using the shell grammar for this.  If you
> type "echo foo", it doesn't matter what IFS is, it will always treat
> that as two words with space as separator.  The other splitting flags
> use IFS.
> 
> > I just found that it looks like the z flag won't cause "forced joining"
> > which stated in rules 10, like this:
> 
> Yes, (z) is not like the other splitting flags.  It's a utility for when you
> need something that obeys shell parsing rules.  It's not a simple
> word-splitting tool, which is what the other splitting flags are for.
> 
> pws
Thanks a lot.


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

end of thread, other threads:[~2012-10-19  9:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-18 22:18 z flag in parameter expansion doesn't use $IFS ? Han Pingtian
2012-10-19  8:26 ` Peter Stephenson
2012-10-19  8:53   ` Han Pingtian

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