From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11464 invoked by alias); 4 May 2016 17:21:50 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21514 Received: (qmail 10670 invoked from network); 4 May 2016 17:21:47 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-transfer-encoding; bh=H8+C334zsI3DLyMLM5h63hJ4by58N5q/5ujNssmNwys=; b=vPNcRqFx8+d6yDz2xy4Nm8VkYDnsmV/bvChzHJdmRSlRS+7PgQoAdg3VOimYi72aeA aB91EGKbBSDt1Zfz6LJ0tLkeAbpIrSAv1fz9lHl4MI8gb+8eohYVgpwEpFJ93GR1MC7+ ZeO6q07C5/5exe+lRqtB6xU95bAAbtkYUJeAe0EYnCnc0A7VGvPIVwpM8K6j2F1vNAe4 ejk5Dhr/hEOZQlCd/mEVGQV4t6tOY56taeIZWV4iN4gbq7pvObgPXFzWNfsyBm5q34JY ag8jeO6tR6YWSe4EKxCE+VKGsZoyj8vIyTNowezNRy1F02aGJeERjaJX21zPBKrWb4DZ Aw5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-transfer-encoding; bh=H8+C334zsI3DLyMLM5h63hJ4by58N5q/5ujNssmNwys=; b=W/hgLY+NYXkcHSXlVQG0FVFSSS+P5wR4d9YQxQyBG0SEA9DF9npHgHvgJKrOOE5YDx ikw3pYFo8DCi9eDIPIiqxr+ASLfjBhUpVagT7G/ilzQhlc0hUpV8Wx60i78oN75ndONl /ZnZXc+CycW1oH6YflehwcBrmfnpZdUFCgIq41BMC+s3/2oRdBQCEshXNcR4tBtG4Jxt OJLS5SwSJrqTsFrGpaxjmkN+tTBA+CqBtXSjrGx3eM1hqBTDixO7hzQl4/0rshoQOkGW DkGNo0xwxwCEodokSf+0AOhDNbitWAk2jMbfTirvg5pN8Bj4xBj7oAaITrE3sTG37t8u HXvQ== X-Gm-Message-State: AOPr4FXVEf/V0oYv2GybfVckgQ9WBRMu6tZ+m+RGQdCQ/aLPnh+CnsOTDT4hw4gl1ryahI/YTpTLhSRZb/ux9Q== MIME-Version: 1.0 X-Received: by 10.25.90.79 with SMTP id o76mr4650759lfb.67.1462382504308; Wed, 04 May 2016 10:21:44 -0700 (PDT) In-Reply-To: <20160504134632.GA5729@aurora-borealis.phear.org> References: <20160504134632.GA5729@aurora-borealis.phear.org> Date: Wed, 4 May 2016 10:21:44 -0700 Message-ID: Subject: Re: make aliases work inside the function? (using a preprocessor?) From: Bart Schaefer To: Marc Chantreux Cc: Zsh Users Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable In addition to what PWS and Oliver have said, it's possibly important to point out that -- On Wed, May 4, 2016 at 6:46 AM, Marc Chantreux wrote: > > % which =E2=82=AC > =E2=82=AC () { > setopt localoptions unset nowarncreateglobal > "$@" } -- aliases are never going to expand with the command word quoted as in your "$@" substitution there. Oliver's suggestion would work, but only because (as he mentioned) the alias would be expanded on the interactive command line before the =E2=82=AC function runs. For this specific example, what you want is probably: =E2=82=AC () { setopt localoptions unset nowarncreateglobal eval "$1" "${(q@)argv[2,-1]}" } The eval will expand aliases in $1 (the desired command word) regardless of the order in which they are defined relative to the function, and the (q@) assures that the rest of the arguments are unmolested by eval. Other uses of aliases need the approach outlined by Peter.