From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Bernd Steinhauser <linux@bernd-steinhauser.de>
Cc: zsh-users@zsh.org
Subject: Re: Mapping quoted parameter in function
Date: Thu, 10 Nov 2016 16:10:49 +0000 [thread overview]
Message-ID: <20161110161049.GA27095@fujitsu.shahaf.local2> (raw)
In-Reply-To: <0a521f25-d548-d3b1-fb2e-7559f7995b7d__49592.623851686$1478759489$gmane$org@bernd-steinhauser.de>
Bernd Steinhauser wrote on Thu, Nov 10, 2016 at 07:20:17 +0100:
> progfunc() {
> CORES=12
> program -n ${CORES} "foo='bar'" foo2="1 $3"
> }
>
> What I would want to do is to ensure that if I call
> `progfunc x`
>
> this would translate into "foo='x'", without touching the rest of the call.
> Is that somehow possible?
If you want to get «x» as your $1 argument and have the callee see
«foo='x'» as its argument, you can do this:
progfunc() { program "foo='$1'" }
Or this:
progfunc() { program "foo=${(q)1}" }
If that doesn't answer your question, then please clarify it.
> iirc, variables won't work, because of the quoting style?
«"foo'$bar"» does interpolate $bar as a variable, despite the single
quote in there, because the ' is literal (part of the string data).
«"foo"'$bar'» doesn't, because the ' is syntactical.
Cheers,
Daniel
> Best Regards,
> Bernd
>
next parent reply other threads:[~2016-11-10 16:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <0a521f25-d548-d3b1-fb2e-7559f7995b7d__49592.623851686$1478759489$gmane$org@bernd-steinhauser.de>
2016-11-10 16:10 ` Daniel Shahaf [this message]
2016-11-10 6:20 Bernd Steinhauser
2016-11-10 12:29 ` Clint Hepner
2016-11-10 16:48 ` Bernd Steinhauser
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=20161110161049.GA27095@fujitsu.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=linux@bernd-steinhauser.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).