I set a variable with spaces in a string to a new bash:
VAR='my variable with spaces' /bin/bash
And now if I want to start a new bash with the same environment, I would do something like:
ENV=$(cat /proc/self/environ | xargs -0 | grep =)
env -i - $ENV /bin/bash
But the thing is, in /proc/self/environ
, this variable is without quotes. So the last command throws a: env: variable: No such file or directory
How can I work around this limitation?
PS: this is a simplified version of the following issue: https://github.com/jpetazzo/nsenter/issues/62