Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Builtin append() and prepend() to PATH, CDPATH, etc.
- X-seq: zsh-workers 1244
- From: Fung-Chai Lim <fclim@xxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx (The Z-shell)
- Subject: Builtin append() and prepend() to PATH, CDPATH, etc.
- Date: Mon, 3 Jun 1996 01:59:27 +0800 (SGT)
Hi,
I have not check the documentation to see if this is already in zsh.
I have not even compile and install the latest version; zsh is evolving
too fast for me to catch up.
Anyway, I am referring to the shell functions named append() and
prepend() that I'd found in Sun's /usr/openwin/bin/openwin.
They are used to add components to colon-separated variables like
PATH, CDPATH, MANPATH, etc, and will only add the component if the
component is not already in the variable.
I would like to see these 2 capabilities built-in into the shell
with some syntactic sugar on top.
For example, zsh has `pushd_ignore_dups'. I think it would be easy
to add a builtin function, say, `uniq-var' that, like `export', accept
a variable list of arguments. An example is
$ uniq-var PATH CDPATH MANPATH
After evaluating this statement, modifying any of the 3 variables
would ensure no duplication:
$ set path = (/usr/local/bin $path /usr/bin)
would prepend /usr/local/bin and append /usr/bin into PATH only if
they are not already in it.
Having such features would help with the current lengthy and redundant
output with "echo $PATH".
Having them builtin would speed up the evaluation of .zprofile.
Thanks in advance.
Regards,
fclim.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author