zsh-users
 help / color / mirror / code / Atom feed
* Word split
@ 1997-11-06 15:49 Bernd Eggink
  1997-11-06 17:44 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Bernd Eggink @ 1997-11-06 15:49 UTC (permalink / raw)
  To: zsh-users mailing list

Hi,

I have a problem with word splitting in 3.1.2:

	x='a::b'
	y=(${(s(:)x})

I wanted $y to hold 3 elements, with an empty $y[2], but the result is
an array with 2 elements, 'a' and 'b'. This would be OK if at least 

	y=("${(@s(:)x}")

gave 3 elements, but it doesn't either. This is inconsistent with the
behaviour of

	setopt shwordsplit; IFS=:; y=($x) 

which results in an array of length 3.

Any comments?

	Bernd

--
Bernd Eggink
Regionales Rechenzentrum der Uni Hamburg
eggink@rrz.uni-hamburg.de
http://www.rrz.uni-hamburg.de/eggink/BEggink.html


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

* Re: Word split
  1997-11-06 15:49 Word split Bernd Eggink
@ 1997-11-06 17:44 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 1997-11-06 17:44 UTC (permalink / raw)
  To: zsh-users mailing list

On Nov 6,  4:49pm, Bernd Eggink wrote:
} Subject: Word split
}
} 	x='a::b'
} 	y=(${(s(:)x})
                  ^
        y=(${(s(:))x})
                  ^
} I wanted $y to hold 3 elements, with an empty $y[2], but the result is
} an array with 2 elements, 'a' and 'b'. This would be OK if at least 
} 
} 	y=("${(@s(:)x}")
                    ^
  	y=("${(@s(:))x}")
                    ^
} gave 3 elements, but it doesn't either.

I thought perhaps this was a problem with using it in the array context,
but ${(ws(:))#x} yeilds 2, so it really is dropping the empty word when
doing the split.

While we're on the subject, is there any chance the manual could get some
more examples added to the parameter expansion section?  It's really not
very easy to understand from the one-line descriptions what something like
${(SI(1)B)x%:} will produce.

"Include the index of the beginning of the match in the result."

Whaddaya mean, "include?"

Well, what you mean is that if you use multiple flags, you get multiple
words in the result:

    zagzig[144] echo ${(SI(1)BE)x%:}
    3 4

But the order of the flags doesn't make any difference:

    zagzig[145] echo ${(SI(1)EB)x%:}
    3 4

And nowhere is it explained what order they're going to show up in:

    zagzig[146] echo ${(SI(1)BR)x%:}
    a:b 3
    zagzig[147] echo ${(SI(1)MR)x%:}
    : a:b
    zagzig[148] echo ${(SI(1)RBM)x%:}
    : a:b 3
    zagzig[149] echo ${(SI(1)RBMN)x%:}
    : a:b 3 1
    zagzig[150] echo ${(SI(1)RBMNE)x%:}
    : a:b 3 4 1

Lots of zsh's features lurk behind this kind of veil of semidocumentation.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


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

end of thread, other threads:[~1997-11-06 17:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-11-06 15:49 Word split Bernd Eggink
1997-11-06 17:44 ` 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).