zsh-users
 help / color / mirror / code / Atom feed
* Effect of typeset -U for colon separated paths?
@ 2001-12-14 13:00 Hannu Koivisto
  2001-12-14 13:08 ` Borsenkow Andrej
  2001-12-14 15:36 ` Bart Schaefer
  0 siblings, 2 replies; 3+ messages in thread
From: Hannu Koivisto @ 2001-12-14 13:00 UTC (permalink / raw)
  To: Zsh Users' List

Greetings,

I have few other colon separated paths in addition to PATH and
MANPATH that need to be managed in a similar fashion.  In PATH's
and MANPATH's case I can avoid duplicates by saying "typeset -U
path manpath" because PATH and MANPATH are special in that they
mirror array parameters path and manpath, respectively.  I couldn't
find any way to establish similar mirroring for arbitrary
variables, though, so I need to get rid of duplicates manually.  I
thought about creating a temporary array, let's call it "foo",
declare its elements unique and then split elements of my colon
separated variables into it and join them back.  Unfortunately I
couldn't get splitting to work.  I tried...

BAR=foo:bar:baz
foo=(${(s:::)BAR}

...but s expansion flag couldn't split with plain ":" (for
understandable reasons).  I couldn't figure out any working way to
quote it either.  How should such splitting be done?  Or are there
alternative, easier ways of getting rid of duplicates in colon
separated paths?

-- 
Hannu
Please don't send copies of list mail


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

* RE: Effect of typeset -U for colon separated paths?
  2001-12-14 13:00 Effect of typeset -U for colon separated paths? Hannu Koivisto
@ 2001-12-14 13:08 ` Borsenkow Andrej
  2001-12-14 15:36 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Borsenkow Andrej @ 2001-12-14 13:08 UTC (permalink / raw)
  To: 'Hannu Koivisto', 'Zsh Users' List'

> I have few other colon separated paths in addition to PATH and
> MANPATH that need to be managed in a similar fashion.  In PATH's
> and MANPATH's case I can avoid duplicates by saying "typeset -U
> path manpath" because PATH and MANPATH are special in that they
> mirror array parameters path and manpath, respectively.  I couldn't
> find any way to establish similar mirroring for arbitrary
> variables,

typeset -T

-andrej


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

* Re: Effect of typeset -U for colon separated paths?
  2001-12-14 13:00 Effect of typeset -U for colon separated paths? Hannu Koivisto
  2001-12-14 13:08 ` Borsenkow Andrej
@ 2001-12-14 15:36 ` Bart Schaefer
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2001-12-14 15:36 UTC (permalink / raw)
  To: Hannu Koivisto, zsh-users

On Dec 14,  3:00pm, Hannu Koivisto wrote:
}
} BAR=foo:bar:baz
} foo=(${(s:::)BAR}
} 
} ...but s expansion flag couldn't split with plain ":" (for
} understandable reasons).  I couldn't figure out any working way to
} quote it either.

Andrej has already mentioned "typeset -T", but to quote the doc for the
flags j, l, r, s, etc.:

 The following flags (except p) are followed by one or more arguments as
 shown.  Any character, or the matching pairs `(...)', `{...}', `[...]',
 or `<...>', may be used in place of a colon as delimiters, but note
 that when a flag takes more than one argument, a matched pair of
 delimiters must surround each argument.

So for example:

    BAR=foo:bar:baz
    foo=(${(s.:.)BAR})



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

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

end of thread, other threads:[~2001-12-14 15:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-14 13:00 Effect of typeset -U for colon separated paths? Hannu Koivisto
2001-12-14 13:08 ` Borsenkow Andrej
2001-12-14 15:36 ` 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).