0

I have a Windows host with some environment variables. I would like to be able to pass them into a Vagrant linux instance to write into a file.

This works for simple values of %foo%.

vagrant ssh -c "echo %foo% | tee -a /tmp/file"

However, if %foo% has a $ in it, it messes up because linux interprets it as a variable.

Is there a way I can automagically escape any $ symbols in %foo% or get linux to not interpret it?

I had found this SO question, but it runs into the same $ problem: Pass environment variables to vagrant shell provisioner

Community
  • 1
  • 1
Marshmellow1328
  • 1,205
  • 3
  • 18
  • 27

1 Answers1

1

Simply quote it with single quotes:

vagrant ssh -c "echo '%foo%' | tee -a /tmp/file"

I just hope %foo% doesn't expand to something that has single quotes as well.

konsolebox
  • 72,135
  • 12
  • 99
  • 105