Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jun 1997 23:31:12 +0200
From:      Ollivier Robert <roberto@keltia.freenix.fr>
To:        freebsd-chat@FreeBSD.ORG
Subject:   Re: OS/2 users going to FreeBSD?  :-)
Message-ID:  <19970620233112.04222@keltia.freenix.fr>
In-Reply-To: <19970620161450.18176@right.PCS>; from Jonathan Lemon on Fri, Jun 20, 1997 at 04:14:51PM -0500
References:  <199706191239.IAA14178@gatekeeper.itribe.net> <19970619215751.20461@keltia.freenix.fr> <slrn5qkc4q.bsi.sec@matrix.42.org> <19970620201858.04493@keltia.freenix.fr> <19970620161450.18176@right.PCS>

next in thread | previous in thread | raw e-mail | index | archive | help
According to Jonathan Lemon:
> I use the alias features of tcsh heavily, especially the "!*" construct, and
> don't want to give that up.  Does zsh support command substitution in 
> aliasing?

Yes. It supports many things from csh too...

Extracted from the FAQ:

    1.  If the csh alias references "parameters" (\!:1 \!* etc.),
        then in zsh you need a function (referencing $1 $* etc.).
        Otherwise, you can use a zsh alias.

    2.  If you use a zsh function, you need to refer _at_least_ to
        $* in the body (inside the { }).  Parameters don't magically
        appear inside the { } the way they get appended to an alias.

    3.  If the csh alias references its own name (alias rm "rm -i"),
        then in a zsh function you need the "command" keyword
        (function rm() { command rm -i $* }), but in a zsh alias
        you don't (alias rm="rm -i").

    4.  If you have aliases that refer to each other (alias ls "ls -C";
        alias lf "ls -F" ==> lf == ls -C -F) then you must either:
        a.  convert all of them to zsh functions; or
        b.  after converting, be sure your .zshrc defines all of your
            aliases before it defines any of your functions.

    Those first four are all you really need, but here are four more for
    heavy csh alias junkies:

    5.  Mapping from csh alias "parameter referencing" into zsh function
        (assuming shwordsplit and ksharrays are NOT set in zsh):
             csh                   zsh
            =====               ==========
            \!*                 $*              (or $argv)
            \!^                 $1              (or $argv[1])
            \!:1                $1
            \!:2                $2              (or $argv[2], etc.)
            \!$                 $*[$#]          (or $argv[$#], or $*[-1])
            \!:1-4              $*[1,4]
            \!:1-               $*[1,$#-1]      (or $*[1,-2])
            \!^-                $*[1,$#-1]
            \!*:q               "$@"            ($*:q doesn't work (yet))
            \!*:x               $=*             ($*:x doesn't work (yet))

I've sent a bug report for %{...%}. We'll see.
-- 
Ollivier ROBERT -=- FreeBSD: There are no limits -=- roberto@keltia.freenix.fr
FreeBSD keltia.freenix.fr 3.0-CURRENT #20: Fri Jun 13 00:16:13 CEST 1997



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19970620233112.04222>