From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 410 invoked from network); 11 Nov 2004 15:31:57 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 11 Nov 2004 15:31:57 -0000 Received: (qmail 5662 invoked from network); 11 Nov 2004 15:31:51 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 11 Nov 2004 15:31:51 -0000 Received: (qmail 21774 invoked by alias); 11 Nov 2004 15:31:43 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8200 Received: (qmail 21765 invoked from network); 11 Nov 2004 15:31:43 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 11 Nov 2004 15:31:43 -0000 Received: (qmail 4644 invoked from network); 11 Nov 2004 15:31:43 -0000 Received: from mailhost1.csr.com (HELO MAILSWEEPER01.csr.com) (81.105.217.43) by a.mx.sunsite.dk with SMTP; 11 Nov 2004 15:31:40 -0000 Received: from exchange03.csr.com (unverified [10.100.137.60]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Thu, 11 Nov 2004 15:30:31 +0000 Received: from csr.com ([10.102.144.127]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Thu, 11 Nov 2004 15:31:16 +0000 To: zsh-users@sunsite.dk Subject: Re: suffix alias In-reply-to: References: <1bvxo3gxze39v$.dlg@thorstenkampe.de> <10999.1100184634@csr.com> Date: Thu, 11 Nov 2004 15:31:39 +0000 Message-ID: <21233.1100187099@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 11 Nov 2004 15:31:16.0263 (UTC) FILETIME=[7BEA5B70:01C4C803] X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=none autolearn=no version=2.63 X-Spam-Hits: 0.0 Thorsten Kampe wrote: > > Thanks. So there is no "builtin" solution for this. I thought of > "command rst2html.py" which is a "kind of solution", too. Generally speaking, shell functions are more flexible. There's no real gain from adding some kind of builtin support in a case like this. Where you would need an internal change is if you wanted to match files by patterns rather than suffixes. > Could you explain a bit what your wrapping function does? I thought someone might ask. exec-py () { # Collect matches in local array files. There might # be more than one match in $path. local -a files # This is a very common trick in zsh for searching paths. # ${^path}/$1 becomes $path[1]/$1 $path[2]/$1 ... # i.e. trial matches that might or might not be real files. # The (N) qualifier removes any elements that don't correspond to files. files=(${^path}/$1(N)) # If we found a file, replace $1 by the path to the first match, # i.e. the earliest in the $path. # If we didn't find the file in path, leave the arguments alone. # A simpler version would be: # (( ${#files} )) && 1=$files[1] (( ${#files} )) && set -- $files[1] "${(@)argv[2,-1]}" # Execute python with the original command line except with # $1 replaced as above. python "$@" } # Use the function instead of python for .py files. alias -s py=exec-py -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.mimesweeper.com **********************************************************************