zsh-workers
 help / color / mirror / code / Atom feed
* Case Sensitivity Bug?
@ 2008-12-16 14:14 Sean B. Palmer
  2008-12-16 14:40 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Sean B. Palmer @ 2008-12-16 14:14 UTC (permalink / raw)
  To: zsh-workers

zsh is doing something very strange on OS X:

$ zsh -c 'echo test; which head'
test
/opt/local/bin/head

$ zsh -c 'date; which head'
Tue Dec 16 13:57:00 GMT 2008
/usr/bin/head

The problem centres around the case-sensitivity of HFS+, the OS X
filesystem. I have two head binaries, one called "head", the standard
unix head, and one called "HEAD", part of perl's lwp library:

$ which head
/usr/bin/head

$ which HEAD
/opt/local/bin/HEAD

As you can see from the echo and date commands, my problem is that
invoking echo first in the shell (or invoking nothing at all) causes
which to work in a case insensitive manner. When date is invoked first
instead, which works in a case sensitive manner.

Why is this so? And how does zsh manage to implement a case sensitive
which at all? Neither sh and bash on OS X have a case sensitive which.
I'm using OS X 10.4.11 (Tiger).

The #zsh channel on Freenode suggested I try using -x for extra
diagnostics, but that didn't help. Someone else asked me to check
$PATH to see if it was modified before or after any command; it is
not. In fact, the whole ENV seems static, so I don't think it's any
ENV related problem.

Some more information that might help you to help me:

$ zsh -c 'echo $ZSH_VERSION'
4.2.3

$ zsh -c 'which head'
/opt/local/bin/head

$ zsh -c 'which HEAD'
/opt/local/bin/HEAD

$ zsh -c 'time echo test; which head'
test
/opt/local/bin/head

$ zsh -c 'time date; which head'
Tue Dec 16 14:02:17 GMT 2008
real    0.008s
user    0.001s
sys     0.004s
cpu     64%
/usr/bin/head

$ zsh -c 'cd ..; which head'
/opt/local/bin/head

$ zsh -c 'ls -ald .; which head'
drwxr-xr-x   196 sbp  sbp  6664 Dec 15 21:36 .
/usr/bin/head

The pattern seems to be that any builtin invocation before which means
that which behaves case insensitively. When a non-builtin is invoked,
then which behaves case sensitively. The sensitivity only depends on
the very first invocation:

$ zsh -c 'which head; date; which head'
/opt/local/bin/head
Tue Dec 16 14:04:52 GMT 2008
/opt/local/bin/head

The context of this bug report is the following thread on MacPorts:

https://trac.macports.org/ticket/17620

As you can see, there's some debate there as to what is *right*;
whether which should or should not be case sensitive on OS X. The main
question for me is how which manages to be case sensitive at all,
since obviously I want to continue using both my head and HEAD
binaries in the normal manner, as I have been doing.

(My .zshrc includes a call to "date", and I don't tend to use any
other shell, so I've never noticed the case sensitivity problem before
until it came up with python_select in this MacPorts bug.)

In other words, if zsh can be case sensitive on OS X then so,
presumably, can MacPorts using the same mechanism. This will fix my
python_select bug more satisfactorily than having to remove the "HEAD"
binary.

Thanks,

-- 
Sean B. Palmer, http://inamidst.com/sbp/


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-12-17 14:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-16 14:14 Case Sensitivity Bug? Sean B. Palmer
2008-12-16 14:40 ` Peter Stephenson
2008-12-17 12:27   ` Sean B. Palmer
2008-12-17 14:10     ` Peter Stephenson

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).