I wanted to relate a mildly amusing event that occured today. It started
inoccently enough when:

chao:/var/service# cat /etc/init.d/svscan-jhriv 
zsh: command not found: cat
zsh: exit 1     cat /etc/init.d/svscan-jhriv

That is odd. I know cat is there.

[EMAIL PROTECTED]:~/nfs-home]% which cat
/usr/bin/cat

Okay, it is there. Why did the one login not see it? Could it be a $PATH
issue?

chao:/var/service# echo $PATH
/export/usr/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/ucb:/etc:/usr/etc:/usr/local/etc:/usr/local/bin:/usr/local/gnu/bin:/software/common/LPRng/frontends/lpr:/export/usr/bin

Nope, not a $PATH issue. So what could it be? I had set $path earlier...

chao:/var/service# echo $path
/export/usr/bin 
/bin:/sbin:/usr/bin:/usr/sbin:/usr/ucb:/etc:/usr/etc:/usr/local/etc:/usr/local/bin:/usr/local/gnu/bin:/software/common/LPRng/frontends/lpr:/export/usr/bin

Interesting. I need to go back through history on this...
chao:/var/service# path=(/export/usr/bin $PATH)

Yep, there it was. The fix, you'll love:

chao:/var/service# PATH=$PATH
chao:/var/service# echo $path
/export/usr/bin /bin /sbin /usr/bin /usr/sbin /usr/ucb /etc /usr/etc 
/usr/local/etc /usr/local/bin /usr/local/gnu/bin 
/software/common/LPRng/frontends/lpr /export/usr/bin
chao:/var/service# which cat
/bin/cat

There, all nicely fixed. zsh has two concepts of $PATH. There is $PATH,
the normal colon delimited $PATH that we all know and love. Then there
is $path, which is an array of all the different path components. This
is never a problem, as when one is updated, the other is kept in sync
automatically.

This also led me to realise that if you want to never accidentally run a
binary, put it in a directory with a colon in the name. $PATH will never
be able to see it (except via the relative components, such as . or ..).
It also indicated that zsh would be able to include such a directory in
it's $path.

-john
-- 
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-list

Reply via email to