From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 78e18f3b for ; Tue, 30 Jul 2019 14:03:39 +0000 (UTC) Received: (qmail 4454 invoked by alias); 30 Jul 2019 14:03:32 -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: List-Unsubscribe: X-Seq: 24115 Received: (qmail 21515 invoked by uid 1010); 30 Jul 2019 14:03:32 -0000 X-Qmail-Scanner-Diagnostics: from mail-ua1-f42.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25524. spamassassin: 3.4.2. Clear:RC:0(209.85.222.42):SA:0(-2.0/5.0):. Processed in 2.890041 secs); 30 Jul 2019 14:03:32 -0000 X-Envelope-From: pierpaolog@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.222.42 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZNqeBrWucc+QC7XSo8tZeLi26MdGoAvHbCD0Ldt5JkQ=; b=OhCSqvDUQEwNErOnk1mZ8xT0zIKMQJ6GlTIvxF5vuktm/7k4qGTpd0ixrTDtwC3tGc 4frT0FCbcUko8EF4odVYH8m1RxcQUWk/foY/jli9JouRKr2FDSb0PpbUj17iZ8xHVdRf U5+xDSOTVAQYs8jjIOn/7yhlBNpV6nWPVY4Xco23EHRQiB+Z4PmTL2+42I+KB0l6DPDo zCtc7uMCgkRYDKFUNisYYUQztSFaQxUXoyQp/GWxhb2uZ0sOFi26LpknXPyeMtk0wrd2 z95ZSX5I7ZanyhooHA+dwk3aLzP+2zZjQXtgiXAuwocUSwiPoaZAAUN0T8XwhG3WIocT Qfng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZNqeBrWucc+QC7XSo8tZeLi26MdGoAvHbCD0Ldt5JkQ=; b=Ti4nx6n0v9s24mJ2Vxt9SFnJBxJLgPsWkmr3o/TAeiyvsdMnV2ueVg2zBg7PG8ailG 2N3Cc6WiTx7Fbh3NF7I4W/KJOj2bTw7q/b/4Z+7PcJFMETUQdn3RNxFyX7+nKGF/nbUO jmDOwsI6CqcyO7cbbfnv7Qjq6tvTSpJwrqvKIGEbeROi9Ua8faoKApeNvMggvqm5V3AS 21VGRLjalrhAZX5XNB4Z7cs8SqhqYuuyMqqxvxHOrJK2SJhFF9vP9xUFlI7IuFxKAXMW 0HrjuDDSxInFJIw5umksyhwco+Q1j4ktB7n3tgy0bnZ6Y/0Mt83kCovuRZD7PxC75PJE n+UQ== X-Gm-Message-State: APjAAAWGSid50d4WOCp5FGrJU8MKBamWd1lGcSne1sLqgTT8g7LsHamV YXwgGTjedzrUeQpax48Q8QLDRtUP2aPvH3k37J0= X-Google-Smtp-Source: APXvYqwf3PIm57DOLNNQZUo7gDNXEOXTah9RjXa72wF808nTA0amgHXPB9koSxMKJmWN1GKosRfGTT/UlzMoGcA8gZc= X-Received: by 2002:ab0:60d4:: with SMTP id g20mr36434409uam.20.1564495374724; Tue, 30 Jul 2019 07:02:54 -0700 (PDT) MIME-Version: 1.0 References: <1564492687.5815.4.camel@samsung.com> In-Reply-To: <1564492687.5815.4.camel@samsung.com> From: Pier Paolo Grassi Date: Tue, 30 Jul 2019 16:02:17 +0200 Message-ID: Subject: Re: variable expansion inside string To: Peter Stephenson Cc: Zsh-Users List Content-Type: multipart/alternative; boundary="000000000000103325058ee677e2" --000000000000103325058ee677e2 Content-Type: text/plain; charset="UTF-8" thank you Peter, I made a mistake in the example code: file="filename.txt" a="*$file*" should have been: file="filename.txt" a='*$file*' with single quotes the behaviour is changed: zsh -fc 'file= filename.txt; a="*$file*"; print "$a"' gives: *filename.txt* instead with single quotes: zsh -fc 'file= filename.txt; a=''*$file*''; print "$a"' gives *$file* I would like the second example to somehow give the result of the first, since I am trying to pass the string from another context where the variable $file is not already defined thanks Pier Paolo Grassi linkedin: https://www.linkedin.com/in/pier-paolo-grassi-19300217 founder: https://www.meetup.com/it-IT/Machine-Learning-TO Il giorno mar 30 lug 2019 alle ore 15:19 Peter Stephenson < p.stephenson@samsung.com> ha scritto: > On Tue, 2019-07-30 at 14:28 +0200, Pier Paolo Grassi wrote: > > Hello, is it possibile to do only variable expansion inside a string, eg: > > > > file="filename.txt" > > a="*$file*" > > If you run zsh -f, you'll see that that's exactly what you normally get, > just > by running > > print "$a" > > --- no eval. > > My best guess is you have the option globsubst set and when you tried > to print the result, you didn't use double quotes at that point, i.e. > you had something like > > print $a > > and the *filename.text* got expanded at that point. > > So the original code is actually fine. > > pws > > --000000000000103325058ee677e2--