zsh-users
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <Stephane.Chazelas@morse.com>
To: zsh-users@sunsite.dk
Cc: Tero Niemela <tero_niemela@yahoo.com>
Subject: Re: Two simple questions
Date: Wed, 15 Sep 2004 11:29:52 +0100	[thread overview]
Message-ID: <20040915102951.GB2228@frhdtmp102861.morse.corp.wan> (raw)
In-Reply-To: <20040915083655.GA1180@DervishD>

On Wed, Sep 15, 2004 at 10:36:56AM +0200, DervishD wrote:
[...]
> > > > path=($^path(N))
> > > > manpath=($^manpath(N)) 
[...]
>     Very clever! :) The '^' makes the '(N)' glob qualifier to be
> added to each element of the array :)) Thanks a lot for the
> explanation, is a very clever way of removing non-existent dirs from
> a list (well, an array in this case).
[...]

All the given solutions seem to forget about one thing about
$PATH. An empty element in it means "current directory".

$path instead of "$path[@]" removes the empty components in it.
That doesn't apply to $^path, though, but to the other
solutions.

$ echo $PATH
/usr/xpg4/bin:/usr/bin:/usr/local/bin:
$ print -rl $path
/usr/xpg4/bin
/usr/bin
/usr/local/bin
$ print -rl "$path[@]"
/usr/xpg4/bin
/usr/bin
/usr/local/bin

$ print -rl ${^path}(N)
/usr/xpg4/bin
/usr/bin
/usr/local/bin
$ 

You can change "" to "." with ${path/(#s)(#e)/.}
but that's slightly different.

$ PATH=/::/bin://bin/
$ print -rl ${(u)${${path/(#s)(#e)/.}//\/##/\/}/(#b)(?)\/(#e)/$match}
/
.
/bin
$ 

(note that ${path/%\//} changes "/" into "".

-- 
Stephane


      reply	other threads:[~2004-09-15 10:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-13 15:52 Tero Niemela
2004-09-13 18:57 ` Björn Lindström
2004-09-13 21:10 ` DervishD
2004-09-14 16:37   ` Tero Niemela
2004-09-14 17:19     ` DervishD
2004-09-14 18:55       ` Tero Niemela
2004-09-14 19:09         ` DervishD
2004-09-15  5:11           ` Tero Niemela
2004-09-15  8:36             ` DervishD
2004-09-15 10:29               ` Stephane Chazelas [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=20040915102951.GB2228@frhdtmp102861.morse.corp.wan \
    --to=stephane.chazelas@morse.com \
    --cc=tero_niemela@yahoo.com \
    --cc=zsh-users@sunsite.dk \
    /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).