Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Global And Local Variables in zsh Functions
- X-seq: zsh-users 20400
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Georg Wittig <nc-wittigge@xxxxxxxxxxxxx>
- Subject: Re: Global And Local Variables in zsh Functions
- Date: Sun, 9 Aug 2015 02:45:46 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=KOOvsTXbC7JDKRO48dZjAnnvv6NZWJl7TM4zCHZhdpI=; b=e0q4ghfipB5KAr0CL2ebNP7V7TuvhmylSP6c0IhYzPxnXt4RnB+qih9FWCzr5mYoiV 12UtXOUDLNurtYa8e0p7IgTUbpM2QQEt98N/bz8612S+kbGUNO6cOIoo63BNkDcuYgSC a/VDjvskfUXtZTiVbdYLtehYhMHkg+AClD0HeQIijLwDb04iobX5ittGbaYZ6l9jvjvo VUsNpqYNh78QU/jIFljDFcEf2d7t0EabcZDtdOBolcQmWuv14rX4AkcD6Qlek+9xDOjB rFP71eGc6u6TY7iCX7VRASl+dg6rV9NhHCoJ4N+C5zUOelDfN6bTrjlrvOkhaD54+u1G AZ+A==
- In-reply-to: <55C68669.8000408@netcologne.de>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <55C68669.8000408@netcologne.de>
On Sun, Aug 9, 2015 at 12:44 AM, Georg Wittig <nc-wittigge@xxxxxxxxxxxxx> wrote:
> Hi,
>
> I'm writing a zsh script that's constructing a rather complex rsync
> command. One part of the script is constructing a list of exclude
> commands for rsync. For this I use a global variable EXC. It is built
> in the following way
>
> EXC=''
> function my_f1 () {
> EXC+=" --exclude='$1'";
> }
> my_f1 /tmp
> my_f1 /opt/windows7
> echo ">>>$EXC<<<"
In addition to the other replies, you'll also want to change EXC to be an array,
EXC=()
my_f1() {
EXC+=( --exclude=$1 )
}
(note lack of quoting is intentional)
Otherwise, you'll have a bad time trying to actually run the command.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author