Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: alias -s doesn't friendly deal with programs having an extension
- X-seq: zsh-workers 23505
- From: Peter Stephenson <pws@xxxxxxx>
- To: Zsh-Workers <zsh-workers@xxxxxxxxxx>
- Subject: Re: alias -s doesn't friendly deal with programs having an extension
- Date: Fri, 01 Jun 2007 11:29:35 +0100
- In-reply-to: <20070601095747.GA23444@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20070601095747.GA23444@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
Maddi Kopfermann wrote:
> Hi, ZSH workers,
>
> after alias pl=perl e.g.
> a program with an extension like e.g. program.pl can no
> longer be invoked without its full path.
In the case of Perl, the fix is simple:
alias -s pl='perl -S'
(although the Perl documentation is now so complicated it took me five
minutes to confirm that...)
More generally, you could write a shell function to do this.
pathfind() {
local dir
for dir in $path; do
if [[ -f $dir/$2 ]]; then
$1 $dir/$2 "${(@)argv[3,-1]}"
return
fi
done
print pathfind: file not found in path: $2
return 255
}
alias -s pl='pathfind perl'
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview
Messages sorted by:
Reverse Date,
Date,
Thread,
Author