Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Mapping quoted parameter in function
- X-seq: zsh-users 22109
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Bernd Steinhauser <linux@xxxxxxxxxxxxxxxxxxxx>
- Subject: Re: Mapping quoted parameter in function
- Date: Thu, 10 Nov 2016 16:10:49 +0000
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= mesmtp; bh=PTn+HCQOPg8LiHzpzn3ja66CrpI=; b=moKPZh3Qq5zVNGDhShkZp HO6Jhki5LokKW3mUeuR43pp71AQxF4HtRUEdL44kYwvyPx2/daq2C8hepd51KyoZ Gj4HSxSyHazz9/VNt0DENFLdrvLC9BtP963VUpDtvTohGuyisvRj0ZWEcxW/R8So pQpkQ+mONCeB2e3hqlIFvY=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= smtpout; bh=PTn+HCQOPg8LiHzpzn3ja66CrpI=; b=L+T6rrTjvsmgfMebghVH LmDSzcMDsxk5cpmsl1bCDILlEFD5qRIHhlmpw02dwoF3q2V1J0VU1ePcR80h6SHv IX9fi3/WACF0ytVdP1nTolVSEoHomFevGFShnPCkqrY1VwVTyAL5rl64gYV2SwsJ dDrbOiA9PMaqkLD1RCll8n4=
- In-reply-to: <0a521f25-d548-d3b1-fb2e-7559f7995b7d__49592.623851686$1478759489$gmane$org@bernd-steinhauser.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: <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
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author