From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14018 invoked by alias); 13 Nov 2016 04:17:18 -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: 22119 Received: (qmail 18769 invoked from network); 13 Nov 2016 04:17:18 -0000 X-Qmail-Scanner-Diagnostics: from mail-qk0-f180.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.220.180):SA:0(0.4/5.0):. Processed in 5.41553 secs); 13 Nov 2016 04:17:18 -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=0.4 required=5.0 tests=FREEMAIL_FROM, FSL_HELO_BARE_IP_2,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_PASS,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: clint.hepner@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.220.180 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=HGkZ8sv7POzQ+03P5lxB8uJc+ZJqVwVIOO5P7WOXyes=; b=Ikyms840zYpmwFYhGwEDSfyS7sqWNoDZScVXTFGQfcgEsP7YQW6k1eOJjys/amb3Mh 8Gp4Mg4sQvHDT+1I0Y/iRO0AACZWDU1GtBWnbD6eYTrlJhPvMydCFWzS9f76D6QGCtB/ Uk4yJu8c4xTsrz7QRrBd6GxgOhwgwO9oOViG/mEsZSDVvPcwCD3dF26Zd+c9vltiziQN j2XCIUJj1UFDd0DZbeLsAiGk7C1XFS7Ouf4lo6u3h8h0hDtTghXNFG/tJ3CF/uWGRKvg z9ceiV+IqyjSB5L4kw2LMyu7+zbWYSO4GrOWYLp+mpXcvsfz1OdMq93cHu6gYr6h9umO KlAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=HGkZ8sv7POzQ+03P5lxB8uJc+ZJqVwVIOO5P7WOXyes=; b=lhd5IbBbN5GmjlLNsLnXQiVD0X2hs4S7wcUMt73Yl533uNTXmpspW/lQ7QUT/7laWH Dm2RveFFEsj3SWs98q1wQlKByyYa6VtV646UPCuGzAO9x7CiwXH1nCW8K2vCveEloaqk u+QxiLuZignlFK/Kxu4TVoAWfTaJAA/Ts4G5dNid9URs/TKmpWdq7dnErmMZ1gRmz4pv YSSQihhgPdpiF+50SDihs6a9hMglXMxwnBSJSgbJ+rbrE6owwTgeHXlx5CRWbRKp0bPD JPzG+qdpG2cS9tCJTOTULylHsqiasziQ1cO6nXNcUkEXsEuDg7AZfX4CAd1NQve2eTLv 0Bng== X-Gm-Message-State: ABUngveLD9XkFR3YO65PXzbTcDTdbQYEHB+4O3bdgs5dp5nEwPeE9RliM+a6IgUgVCmeIA== X-Received: by 10.55.197.72 with SMTP id p69mr5028814qki.241.1478780997107; Thu, 10 Nov 2016 04:29:57 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 10.1 \(3251\)) Subject: Re: Mapping quoted parameter in function From: Clint Hepner In-Reply-To: <0a521f25-d548-d3b1-fb2e-7559f7995b7d@bernd-steinhauser.de> Date: Thu, 10 Nov 2016 07:29:55 -0500 Cc: zsh-users@zsh.org Content-Transfer-Encoding: quoted-printable Message-Id: <22F03E0F-5C12-41EC-BD57-72139A3534D7@gmail.com> References: <0a521f25-d548-d3b1-fb2e-7559f7995b7d@bernd-steinhauser.de> To: Bernd Steinhauser X-Mailer: Apple Mail (2.3251) > On 2016 Nov 10 , at 1:20 a, Bernd Steinhauser = wrote: >=20 > Hi, >=20 > I'm using a program that expects a parameter (actually multiple = parameters) in the form > program "foo=3D'bar'" >=20 > Because the cmdline for that program gets quite long, I wrote a = function to call it and change parameters easily,it looks roughly like = this: > progfunc() { > CORES=3D12 > program -n ${CORES} "foo=3D'bar'" foo2=3D"1 $3" > } >=20 > What I would want to do is to ensure that if I call > `progfunc x` >=20 > this would translate into "foo=3D'x'", without touching the rest of = the call. > Is that somehow possible? > iirc, variables won't work, because of the quoting style? >=20 > Best Regards, > Bernd Just replace bar with a parameter default expansion. progfunc () { CORES=3D12 program -n $CORES "foo=3D'${1:-bar}' foo2=3D"1 $3" } progfunc # foo=3D'bar' progfunc "hi there" # foo=3D'hi there' If you don=E2=80=99t pass a first argument, bar is used. Otherwise, the = value of the argument is. The single quotes here don=E2=80=99t actually quote anything; they are = literal characters included in the *double*-quoted string. Clint=