Not realising I had caps-lock on, I typed CD into the command prompt on my mac. Surprisingly, it didn't error.
which CD shows me /usr/bin/CD. And if I examine that file, it looks like this:
#!/bin/sh
# $FreeBSD: src/usr.bin/alias/generic.sh,v 1.2 2005/10/24 22:32:19 cperciva Exp $
# This file is in the public domain.
builtin `echo ${0##*/} | tr \[:upper:] \[:lower:]` ${1+"$@"}
I guess it's something to do with translating upper to lower case, but ${0##*/} is completely opaque to me. man CD tells me "no manual entry". Can someone explain this command?
EDIT: Ok, I just noticed that OSX's filesystem is case-insensitive, so this file is actually /usr/bin/cd. But if I type cd normally, I of course get the builtin, so /usr/bin/cd only gets called when I get my case wrong. I'd still like to know what it does.