zsh-users
 help / color / mirror / code / Atom feed
From: ZyX <kp-pav@yandex.ru>
To: Ray Andrews <rayandrews@eastlink.ca>,
	"zsh-users@zsh.org" <zsh-users@zsh.org>
Subject: Re: convolutions
Date: Sat, 07 Nov 2015 20:26:06 +0300	[thread overview]
Message-ID: <1025851446917166@web24h.yandex.ru> (raw)
In-Reply-To: <563E1A54.4000805@eastlink.ca>

07.11.2015, 18:37, "Ray Andrews" <rayandrews@eastlink.ca>:
> On 11/06/2015 10:38 PM, Mikael Magnusson wrote:
>>  No, because 'expanding into "\e"' means nothing useful, did you mean a
>>  literal backslash followed by an e, or a literal escape?
>
> It's not arguable sir. If you found it vague, then you found it vague,
> but to me:
>
>       " \e[31;1m "
>
> ... is very obviously a color code which I hold in my variable " ${red}
> " and I want to expand it inside a file.
>
>>  If you store the string in a parameter and echo that parameter, the
>>  color variables also don't expand.
>>>  So you have a file with "${red}" in it, and you want to read in the
>>>  file, and substitute the value of any parameter references.
>
> Exactly.
>>>  Moreover,
>>>  these parameters are not defined in the file, but are set in the shell
>>>  environment and you happen to know that they are string
>>>  representations of color escape sequences, and you want to expand
>>>  these as well.
>
> Of course. Who but me knows what's in my environment variables?
>>>  If your file has a semicolon in it somewhere, then your command will
>>>  run arbitrary code. Bart's example doesn't have that exact problem,
>>>  but will still execute code if there are things like $(command) in the
>>>  file.
>
> Yes, I know how dangerous eval is, that's why I'm asking for a better
> idea--some way of expanding parameters inside a file. Not just color
> variables really, any variables.

I have no idea why you need such a thing, and need this *in zsh*. This is a job for a template engine, numerous of which exist for every script language out there used for writing something for web (which does not include zsh). Otherwise there already were three solutions, with different downsides. Also see http://stackoverflow.com/questions/2914220/bash-templating-how-to-build-configuration-files-from-templates-with-bash/2916159?noredirect=1#comment46735969_2916159, this can be ported to zsh very easily (note the comments).

Still asking this here looks either like an XY problem or wrong choice of instruments.


  reply	other threads:[~2015-11-07 17: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         ` ZyX [this message]
2015-11-07  5:38 ` convolutions Bart Schaefer
2015-11-07  6:33   ` convolutions Ray Andrews
2015-11-07  9:32     ` convolutions Bart Schaefer
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=1025851446917166@web24h.yandex.ru \
    --to=kp-pav@yandex.ru \
    --cc=rayandrews@eastlink.ca \
    --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).