Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Tidying MANPATH
- X-seq: zsh-users 13172
- From: Daniel Qarras <dqarras@xxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Tidying MANPATH
- Date: Sun, 31 Aug 2008 02:34:31 -0700 (PDT)
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Mailer:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Message-ID; b=uSPaSkKfjHf35RDaWzCcyN8W0pcRW/Pw3c9gSE+WW2yN+v+JFgWEH4jxUBvLphlEU03mVSmk17U0dnd6TdclI/is9baPpnPO3WF6OSeaOF0RmaAQ/QqEtLxIp9Nbctm5w2dBv3bhVUPahwSOEdX+KI2AaITAX3iG2qdmgiZq3X4=;
- In-reply-to: <179536.23163.qm@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Reply-to: dqarras@xxxxxxxxx
Hi!
> MANPATH=/path1:/path2::/path3
>
> That means that system manpaths are searched after /path1
> and /path2 but before /path3. The problem is that while
>
> manpath=($^manpath(N))
After few hours of experimenting I was able to come up with these lines, they're surely ugly but seem to work well:
# Testing only
mkdir -p "/tmp/test dir"
export MANPATH="//usr//:/tmp/test dir:///notdir//::/bin://usr///://etc//:/var/"
echo "MANPATH before: $MANPATH"
# Remove non-existing directories
path=($^path(N^M))
[[ -n "$MANPATH" ]] && export MANPATH=${MANPATH//::/:/:}
[[ -n "$MANPATH" ]] && manpath=($^manpath(N^M))
# Remove duplicate and trailing slashes
setopt EXTENDED_GLOB
path=(${${path//\/##/\/}%/})
[[ -n "$MANPATH" ]] && export MANPATH=${${${MANPATH//\/##/\/}//\/:/:}%/}
unsetopt EXTENDED_GLOB
[[ -n "$MANPATH" ]] && export MANPATH=${MANPATH//:\/:/::}
# Remove duplicate directories
typeset -U path manpath
echo "MANPATH after : $MANPATH"
And output for those echoes is:
MANPATH before: //usr//:/tmp/test dir:///notdir//::/bin://usr///://etc//:/var/
MANPATH after : /usr:/tmp/test dir::/bin:/etc:/var
Due to extreme ugliness I might remove the duplicate/trailing slash cleaning but most importantly the non-existing and duplicate dirs are now removed ok while still preserving :: in MANPATH.
Cheers!
Messages sorted by:
Reverse Date,
Date,
Thread,
Author