From: Mikael Magnusson <mikachu@gmail.com>
To: Georg Wittig <nc-wittigge@netcologne.de>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Global And Local Variables in zsh Functions
Date: Sun, 9 Aug 2015 02:45:46 +0200 [thread overview]
Message-ID: <CAHYJk3QnozHuC6FGLDxNTMg4rdAEa8+4JmgBFGHh8QP6HddMTQ@mail.gmail.com> (raw)
In-Reply-To: <55C68669.8000408@netcologne.de>
On Sun, Aug 9, 2015 at 12:44 AM, Georg Wittig <nc-wittigge@netcologne.de> 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
prev parent reply other threads:[~2015-08-09 0:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-08 22:44 Georg Wittig
2015-08-09 0:26 ` ZyX
2015-08-09 0:31 ` Bart Schaefer
2015-08-09 0:45 ` Mikael Magnusson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAHYJk3QnozHuC6FGLDxNTMg4rdAEa8+4JmgBFGHh8QP6HddMTQ@mail.gmail.com \
--to=mikachu@gmail.com \
--cc=nc-wittigge@netcologne.de \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).