From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7972 invoked from network); 21 Apr 2007 15:12:48 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.8 (2007-02-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,FORGED_RCVD_HELO autolearn=ham version=3.1.8 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 21 Apr 2007 15:12:48 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 40271 invoked from network); 21 Apr 2007 15:12:41 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 21 Apr 2007 15:12:41 -0000 Received: (qmail 8835 invoked by alias); 21 Apr 2007 15:12:30 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11440 Received: (qmail 8826 invoked from network); 21 Apr 2007 15:12:30 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 21 Apr 2007 15:12:30 -0000 Received: (qmail 39032 invoked from network); 21 Apr 2007 15:12:30 -0000 Received: from atom.smasher.org (69.55.237.145) by a.mx.sunsite.dk with SMTP; 21 Apr 2007 15:12:27 -0000 Received: (qmail 58927 invoked by uid 1000); 21 Apr 2007 15:12:26 -0000 Message-ID: <20070421151225.58926.qmail@smasher.org> Content-Type: TEXT/PLAIN; charset=US-ASCII Date: Sun, 22 Apr 2007 03:12:21 +1200 (NZST) From: Atom Smasher MIME-Version: 1.0 OpenPGP: id=0xB88D52E4D9F57808; algo=1 (RSA); size=4096; url=http://atom.smasher.org/pgp.txt Subject: Re: cd to a file To: zsh-users@sunsite.dk X-POM: The Moon is Waxing Crescent (23% of Full) X-Hashcash: 1:20:0704211512:zsh-users@sunsite.dk::WK4D0Wado0bJ3A2Y:0000000000000 0000000000000000000000000mxi not nearly as elaborate as Frank Terbeck's function, but i think this provides the basic functionality to cd to a file without breaking anything. the "echo" command is very much optional... cd() { ## cd to a file if [ 1 = "${#}" ] && [ '-' != "${1}" ] && [ \! -d "${1}" ] && [ -d "${1:h}" ] then echo "correcting \"${1}\" to \"${1:h}\"" >&2 builtin cd "${1:h}" else builtin cd "${@}" fi } -- ...atom ________________________ http://atom.smasher.org/ 762A 3B98 A3C3 96C9 C6B7 582A B88D 52E4 D9F5 7808 ------------------------------------------------- "We must have strong minds, ready to accept facts as they are." -- President Harry Truman "I don't care what the facts are." -- President George H.W. Bush, 1988