From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: convolutions
Date: Sat, 7 Nov 2015 01:32:44 -0800 [thread overview]
Message-ID: <151107013244.ZM23334@torch.brasslantern.com> (raw)
In-Reply-To: <563D9B54.9010604@eastlink.ca>
On Nov 6, 10:33pm, Ray Andrews wrote:
} Subject: Re: convolutions
}
} I did indeed edit it a bit. Here's the pasted actual test file:
}
} test2 ()
} {
} echo "$(eval echo "\${$(cat junk1)}")" >! junk2
} cat junk2
} }
}
} ... which works as advertised.
That will fail with "bad substitution" for anything more than a single
word in the file "junk1".
torch% echo "this is some text" > junk1
torch% test2 ()
{
echo "$(eval echo "\${$(cat junk1)}")" >! junk2
cat junk2
}
torch% test2
(eval):1: bad substitution
torch%
You can't just throw ${ } around any arbitrary thing and have it act
like a parameter expansion -- which is what is happening during the
eval when you have used \$ in the original expression:
torch% setopt xtrace verbose
torch% test2
test2
+Src/zsh:25> test2
+test2:2> cat junk1
+test2:2> eval echo '${this is some text}'
(eval):1: bad substitution
+test2:2> echo ''
+test2:3> cat junk2
torch%
-- and you don't even need it there in this case:
torch% test2 ()
{
echo "$(eval echo "$(cat junk1)")" >! junk2
cat junk2
}
torch% some=OTHER
torch% echo 'this is $some text' >| junk1
torch% test2
this is OTHER text
torch%
} > print -R "${(e)$(<in_file)}" >| out_file
}
} Does the trick, thanks, it's no shorter, but much more respectable.
} print has many tricks up it's sleeve.
Sigh. No, "-R" is explicitly telling "print" not to do any tricks at
all. It's the (e) parameter expansion flag that's doing the work.
next prev parent reply other threads:[~2015-11-07 9:32 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-07 2:15 convolutions Ray Andrews
2015-11-07 2:49 ` convolutions ZyX
2015-11-07 4:10 ` convolutions Ray Andrews
2015-11-07 5:37 ` convolutions Mikael Magnusson
2015-11-07 6:16 ` convolutions Ray Andrews
2015-11-07 6:38 ` convolutions Mikael Magnusson
2015-11-07 15:35 ` convolutions Ray Andrews
2015-11-07 17:26 ` convolutions ZyX
2015-11-07 5:38 ` convolutions Bart Schaefer
2015-11-07 6:33 ` convolutions Ray Andrews
2015-11-07 9:32 ` Bart Schaefer [this message]
2015-11-07 9:40 ` convolutions Bart Schaefer
2015-11-07 16:09 ` convolutions Ray Andrews
2015-11-07 17:33 ` convolutions Bart Schaefer
2015-11-07 18:28 ` convolutions Ray Andrews
2015-11-07 17:17 ` convolutions Martin Vaeth
2015-11-08 15:27 ` convolutions Ray Andrews
2015-11-08 19:14 ` convolutions Bart Schaefer
2015-11-08 21:06 ` convolutions Ray Andrews
2015-11-09 8:50 ` convolutions Martin Vaeth
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=151107013244.ZM23334@torch.brasslantern.com \
--to=schaefer@brasslantern.com \
--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).