Zsh Mailing List Archive
Messages sorted by:
Re: variable expansion inside string
- X-seq: zsh-users 24115
- From: Pier Paolo Grassi <pierpaolog@xxxxxxxxx>
- To: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- Subject: Re: variable expansion inside string
- Date: Tue, 30 Jul 2019 16:02:17 +0200
- Cc: Zsh-Users List <zsh-users@xxxxxxx>
- 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==
- In-reply-to: <email@example.com>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:email@example.com>
- List-unsubscribe: <mailto:firstname.lastname@example.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CGME20190730123021epcas1p21671587b575bd82a2512bcb1fa091563@epcas1p2.samsung.com> <CAP+y1xAZiPn1B-GDPZw27fzBMdXSHbr+N3cgJBjOe_MeKGemail@example.com> <firstname.lastname@example.org>
thank you Peter, I made a mistake in the example code:
should have been:
with single quotes the behaviour is changed:
zsh -fc 'file= filename.txt; a="*$file*"; print "$a"'
instead with single quotes:
zsh -fc 'file= filename.txt; a=''*$file*''; print "$a"'
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
Pier Paolo Grassi
Il giorno mar 30 lug 2019 alle ore 15:19 Peter Stephenson <
p.stephenson@xxxxxxxxxxx> 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,
> 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.
Messages sorted by: