Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

path vs. PATH, and other issues



	ok.  so i have a function that has been working fine on my
desktop machine, running zsh 3.1.5, for a while now, as follows:

#!/usr/local/bin/zsh -f
addpath () {
   local PATHVAR=$1 ; shift
   eval local TEMP_ARRAY=\$${PATHVAR}
   TEMP_ARRAY=(${TEMP_ARRAY:gs/:/ /})
   local ARRAY_TO_ADD=${(j< >)@}
   ARRAY_TO_ADD=${ARRAY_TO_ADD:gs/:/ /}
   for DIR_TO_ADD in ${=ARRAY_TO_ADD} ; do
      if [[ -d ${DIR_TO_ADD} ]] ; then
         if [[ -n ${TEMP_ARRAY} ]] ; then 
            TEMP_ARRAY=(${=TEMP_ARRAY} ${DIR_TO_ADD})
         else
            TEMP_ARRAY=(${DIR_TO_ADD})
         fi;
      fi;
   done;
   typeset -U TEMP_ARRAY
   echo "TEMP ARRAY: $TEMP_ARRAY"
   echo $PATH
   eval "export ${PATHVAR}=${(j<:>)TEMP_ARRAY}"
};

	this function, once loaded, lets me do things in my init
files like

   addpath PATH /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
   addpath PATH /usr/ccs/bin /usr/ucb /usr/proc/bin
   addpath PATH /usr/dt/bin:/usr/openwin/bin:/usr/lib/lp/postscript
#   addpath PATH /opt/netscape:/opt/samba/bin:/opt/SUNWwabi/bin:/opt/hpnp/bin
   addpath PATH /home/sweth/bin:/home/sweth/working:.
   addpath MANPATH /usr/man /usr/share/man /usr/local/man:/usr/X/man
   addpath MANPATH /usr/dt/man:/opt/hpnp/man:/opt/samba/man
   addpath LD_LIBRARY_PATH /usr/lib:/usr/local/lib:/usr/ucblib/:/usr/X/lib
   addpath LD_LIBRARY_PATH /usr/openwin/lib:/usr/dt/lib

	and end up with the PATH-like variables I am referencing being set to
strings of colon-separated unique names of directories that exist on the local
system.

	i recently exported my home directories from this machine to another
machine running the same os and same zsh version.  when i log in to that machine,
the line above that i have commented out (for /opt/netscape, etc.) produces an
error of

/home/sweth/.zsh/initialize: not an identifier: /sbin

	where /home/sweth/.zsh/initialize is the script that is running the above
commands.  after this happens, $PATH is set to 

/bin:/home/sweth/bin:/home/sweth/working:.

	and $path is completely unset.  commenting the offending line out makes
everything work fine.  the only thing distinctive that i can think of about that
line is that, on the machine to which i've just started logging in, none of the
listed directories exist; that, however, was why i made this function in the first
place--to not add non-existant directories to my path but be able to keep one
generic config file.

	two questions: one, why is addpath failing on that line; and two, how can
$path be unset if $PATH is set?  (and a third: it appears that $path is the 
parameter that is actually used for finding executables, since after this error i 
have to specify all paths explicitly.  is this the case?)

	-- sweth.

-- 
Sweth Chandramouli
IS Coordinator, The George Washington University
<sweth@xxxxxxx> / (202) 994 - 8521 (V) / (202) 994 - 0458 (F)
<a href="http://astaroth.nit.gwu.edu/~sweth/disc.html";>*</a>



Messages sorted by: Reverse Date, Date, Thread, Author