zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: zsh-users mailing list <zsh-users@math.gatech.edu>
Subject: Re: Word split
Date: Thu, 6 Nov 1997 09:44:37 -0800	[thread overview]
Message-ID: <971106094437.ZM25281@candle.brasslantern.com> (raw)
In-Reply-To: <3461E726.5327813E@rrz.uni-hamburg.de>

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


      reply	other threads:[~1997-11-06 17:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-11-06 15:49 Bernd Eggink
1997-11-06 17:44 ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=971106094437.ZM25281@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).